Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

rotor posted:

HTml Application. It's basically a balled up wad of html & scripts (vbscript usually) that looks like an application to the user - sort of like a CHM. I don't think it has fwd & back buttons, hence the question.

http://www.microsoft.com/technet/scriptcenter/hubs/htas.mspx

I've always been surprised that they're not more popular.

Ah, OK, so it's like Adobe AIR, but windows-only. I wondered why AIR was never more popular, but the more I thought about it, when you start developing these things(AIR apps and HTMs,) you generally get more complex than "just a web page" and are tracking view states, need to swap objects on screen out, need to write out data to files, have to have more complex error-handling, etc. So many who would find the ease of entry ("hey, you already know HTML and javascript!") are a bit un-prepared / overwhelmed by all the additional stuff they need to code, and those who are prepared for all the extra bits probably just say "gently caress it, I'll write it in C, C#, Java, Objective-C , [INSERT LANGUAGE HERE]"

Thanks for the info on HTAs. I actually have a "web" app deployed that is IE-6 only (used internally in a call center) that I frequently wish I could bust out of the browser sandbox a bit. It requires OCX controls, so I couldn't do it in AIR, but this might be the bee's knees.

Adbot
ADBOT LOVES YOU

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

Lumpy posted:

Ah, OK, so it's like Adobe AIR, but windows-only.

You have absolutely no clue what AIR is! :bravo:

edit: I stand by my point since you argue that all the extra "stuff" (i/o, state, etc) that AIR provides to Flex is somehow comparable to a few static html files bundled together. And if you want to use all that extra "stuff" you're going to have to go with a more complex language like C#.

That makes no sense at all because that's exactly what AIR does: gives you functionality that would be pretty drat useful if you wish to write a true application in flash.

karms fucked around with this message at 16:27 on Mar 11, 2009

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Mercator posted:

You have absolutely no clue what AIR is. :bravo:

Really? Wow, then I better trash all the AIR apps I've written. It's likely I don't understand what HTAs are, but don't let that stop you from being a douche.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
FWIW, HTAs let you read/write to the filesystem, so comparing them to AIR is at least in the ballpark.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

sonic bed head posted:

They are IE/Windows only AFAIK.

something being IE/Windows only never really had much bearing on whether it was popular or not.

joojoo2915
Jun 3, 2006
code:
(function() {
  var oldonload = window.onload;
  window.onload = function() {
    if (oldonload)
      oldonload();
	  
	  if (!document.forms.futuresSeasonal.contractSelect.value){
var GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>';}
else{
var GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>&fs='+document.forms.futuresSeasonal.contractSelect.value;
}
    buildMovieFromXML(GOGRAIN_XML_URL);
  };
})();
So I have my page set up with a default value if nothing from the drop down select list is selected, however when something is selected I need a new URL passed to the XML parser with that drop down menu selection as part of the querystring. I realize my code here is a horrible abortion mix of javascript and asp, but I know for a fact the asp parts work, it is just the javascript I'm having trouble with. If I hard code the URL with a possible drop down option like so:

code:
var GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>&fs='C2009N';
it works fine so I assume it is a problem with how I am trying to retrieve the form value, but from what little I know about javascript it looks right to me. Any help would be super awesome.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

joojoo2915 posted:

code:
(function() {
  var oldonload = window.onload;
  window.onload = function() {
    if (oldonload)
      oldonload();
	
[REMOVED TABLE BREAKING STUFF]

    buildMovieFromXML(GOGRAIN_XML_URL);
  };
})();
So I have my page set up with a default value if nothing from the drop down select list is selected, however when something is selected I need a new URL passed to the XML parser with that drop down menu selection as part of the querystring. I realize my code here is a horrible abortion mix of javascript and asp, but I know for a fact the asp parts work, it is just the javascript I'm having trouble with. If I hard code the URL with a possible drop down option like so:

code:
var GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>&fs='C2009N';
it works fine so I assume it is a problem with how I am trying to retrieve the form value, but from what little I know about javascript it looks right to me. Any help would be super awesome.

Without seeing the HTML it's impossible to tell if what you are doing is "correct" but if you are getting the value of a SELECT you need to do something along the lines of:

code:
document.forms.futuresSeasonal.contractSelect.options[document.forms.futuresSeasonal.contractSelect.selectedIndex].value);
Since the SELECT doesn't have a value by itself, it's the sweet sweet OPTIONs inside that do.

Or, use jQuery and do $('#selectID').val();

Melraidin
Oct 11, 2005

joojoo2915 posted:

code:
(function() {
  var oldonload = window.onload;
  window.onload = function() {
    if (oldonload)
      oldonload();
	  
	  if (!document.forms.futuresSeasonal.contractSelect.value){
var GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>';}
else{
var GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>&fs='+document.forms.futuresSeasonal.contractSelect.value;
}
    buildMovieFromXML(GOGRAIN_XML_URL);
  };
})();
[...]

First guess: define GOGRAIN_XML_URL outside of the if statement, then inside it do not use "var". Right now it looks like you're probably passing "undefined" to buildMovieFromXML as GOGRAIN_XML_URL doesn't exist outside that if statement in your code.

Try this:

code:
var GOGRAIN_XML_URL = false;

	  if (!document.forms.futuresSeasonal.contractSelect.value){
GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>';}
else{
GOGRAIN_XML_URL = 'XML/futures_seasonal_chart_new.asp?ticker=<%=crop_letter%>&cropy=<%=Cropy%>&fs='+document.forms.futuresSeasonal.contractSelect.value;
}
    buildMovieFromXML(GOGRAIN_XML_URL);

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Melraidin posted:

First guess: define GOGRAIN_XML_URL outside of the if statement, then inside it do not use "var". Right now it looks like you're probably passing "undefined" to buildMovieFromXML as GOGRAIN_XML_URL doesn't exist outside that if statement in your code.

Try this:



Huh? He passes it as an argument before the function ends, and javascript passes by value, not reference, so it's not undefined. Using 'var' twice like that is ugly, but it works in javascript.

code:
function whee(val)
{
  if(val)
  {
    var box = "square";
  }else{
    var box = "rectangle";
  }
  blah(box);
}
function blah(str)
{
  alert("Your box is a "+str);
}
whee(false);
Works just fine, and so will his code. His problem is not knowing how to get a SELECT input value.

Lumpy fucked around with this message at 15:19 on Mar 13, 2009

Melraidin
Oct 11, 2005

Lumpy posted:

Huh? He passes it as an argument before the function ends, and javascript passes by value, not reference, so it's not undefined. Using 'var' twice like that is ugly, but it works in javascript.
[...]

Well drat, you're entirely correct. I was thinking that the variable would fall out of scope as soon as execution left the if-block. Tested and I was wrong, dammit.

Sylink
Apr 17, 2004

Is it possible to dynamically change the size of a canvas in javascript instead of specifying like below?

code:

 <body onload="draw()">
   <canvas id="canvas" width="600" height="400"></canvas>
 </body>
</html>

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Sylink posted:

Is it possible to dynamically change the size of a canvas in javascript instead of specifying like below?

code:

 <body onload="draw()">
   <canvas id="canvas" width="600" height="400"></canvas>
 </body>
</html>

This resized for me, so I'm guessing yes:

code:
<html>
<head>
<script language="javascript" src="js/jquery.js"></script>
<script>
function lol()
{
	jQuery('#myCanvas').css("height","600px");
}
</script>
<style>
	#myCanvas { border: 1px #006 solid; }
</style>
</head>
<body>
<input type="button" onclick="lol()" value="pres butan" />
<br />
<canvas id="myCanvas" width="600" height="400"></canvas>
</body>
</html>
I used jQuery because I'm lazy :)

[EDIT]
This made a new one and sized it appropriately:

code:
<html>
<head>
<script language="javascript" src="js/jquery.js"></script>
<script>
function lol()
{
	var newCanvas = jQuery("<canvas class='borderMe'></canvas>");
	newCanvas.css("height","200px").css("width","500px");
	jQuery('#whee').append(newCanvas);
}
</script>
<style>
	.borderMe { border: 1px #006 solid; }
</style>
</head>
<body>
<input type="button" onclick="lol()" value="pres butan" />
<br />
<div id="whee"></div>
</body>
</html>
\/\/ if it was Jessica Alba's rear end, that could be a good thing.

Lumpy fucked around with this message at 04:46 on Apr 2, 2009

Sylink
Apr 17, 2004

I got it working but not to my liking, I realized that the canvas is a bitmap so resizing makes it look like rear end.

Sylink fucked around with this message at 03:22 on Apr 2, 2009

ApeEscape
Apr 23, 2008
I don't think this is worth it's own thread so here goes. Does anyone have/know of a site that has a free time entry code to be used on a web form? I want to have the user be able to enter a valid time by either giving them a drop down for hour, month, AM/PM that looks somewhat clean. Currently, I am using an Ajax time extender on a texbox (ASP.NET), but that is utterly atrocious and the time entry is very obscure. So that's why I would rather user Javascript if possible.

Thanks!

Hi I am a Snake
Jun 10, 2008

by Fistgrrl
This is a simple question but I cannot figure it out. Please help.

code:
 function stat(value)
 {
  this.value=value;
 }

 function test()
 { 
  alert(this.value);
  alert(bob.value);
 }

bob=new stat(100);
And in the body of the page

code:
<input type=button value="Change" name=choice onclick="test(bob)">
Two alerts come up: the first reads "undefined" and the second reads "100". Why aren't they the same?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Hi I am a Snake posted:

Two alerts come up: the first reads "undefined" and the second reads "100". Why aren't they the same?

Because this does not refer to bob. I'm not sure why you think it would, really. The onclick event you specified has nothing to do with bob at all.

Hi I am a Snake
Jun 10, 2008

by Fistgrrl
Man I'm dumb.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Anyway, if you want something like bob.test() you need to specify test as a method:

code:
function stat(value)
{
    this.value=value;
    this.test = function() { /* ... */ };
}

// or

stat.prototype.test = function()
{
    // ...
}

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Hi I am a Snake posted:

This is a simple question but I cannot figure it out. Please help.


What Avenging Dentist said, and here's some good reading on this stuff: http://javascript.crockford.com/private.html

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Lumpy posted:

What Avenging Dentist said, and here's some good reading on this stuff: http://javascript.crockford.com/private.html

That's a nice link (as much as that stuff looks like a hack than a programming "convention", it's cool that that stuff is possible).

On that note, are there any good reference books that examine JavaScript outside the context of web development? JS has some interesting and powerful capabilities on its own as a language (especially in the latest versions) and I'd love to read a volume on advanced techniques like the one above. (This was spawned by my using JavaScript as part of the Eclipse BIRT reporting engine in order to transform data in reports I'm working with.)

Unfortunately I've never seen such a book -- everything published about JavaScript seems to focus on "here's how you make your web page to wacky things!!!"

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
Actionscript :rimshot:.

There's always Rhino.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Mercator posted:

Actionscript :rimshot:.

There's always Rhino.

Err, I think you misread my question. I'm not looking for a JS interpreter (in fact BIRT comes with Rhino for doing its reports), I'm looking for a comprehensive reference that talks about advanced JavaScript feature more in terms of a programming language in its own right and less as a web development add-on.

SuckerPunched
Dec 20, 2006

Flobbster posted:

Err, I think you misread my question. I'm not looking for a JS interpreter (in fact BIRT comes with Rhino for doing its reports), I'm looking for a comprehensive reference that talks about advanced JavaScript feature more in terms of a programming language in its own right and less as a web development add-on.

Douglas Crockford's books are pretty good for this. His latest, java script: The Good Parts is a great resource and is probably along the lines of what you're looking for. Take a look through the Table of Contents.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

SuckerPunched posted:

Douglas Crockford's books are pretty good for this. His latest, java script: The Good Parts is a great resource and is probably along the lines of what you're looking for. Take a look through the Table of Contents.

Awesome, that's exactly the kind of reference I was looking for (and it looks fairly recent which is probably why I never came across it before). Thanks!

Tivac
Feb 18, 2003

No matter how things may seem to change, never forget who you are

Flobbster posted:

Awesome, that's exactly the kind of reference I was looking for (and it looks fairly recent which is probably why I never came across it before). Thanks!

Crockford's awesome do whatever he tells you.

Sock on a Fish
Jul 17, 2004

What if that thing I said?
I've got a really simple call to a really simple Prototype function that appears to be timing out after about five minutes or so:
code:
	<script type="text/javascript" charset="utf-8">
		new Ajax.PeriodicalUpdater('log', '$someurl',
		  {
		    method: 'get',
		    frequency: 1,
		  });
	</script>
The script is supposed to give feedback by automatically updating the page from a log file that's exposed on a web server. Is this timeout I'm seeing just something that the browser does if it sees some Javascript that's kicking off every second and not producing any results? I didn't read about any kind of default timeout in the docs, and Google doesn't reveal anything useful.

sonic bed head
Dec 18, 2003

this is naturual, baby!

Sock on a Fish posted:

I've got a really simple call to a really simple Prototype function that appears to be timing out after about five minutes or so:
code:
	<script type="text/javascript" charset="utf-8">
		new Ajax.PeriodicalUpdater('log', '$someurl',
		  {
		    method: 'get',
		    frequency: 1,
		  });
	</script>
The script is supposed to give feedback by automatically updating the page from a log file that's exposed on a web server. Is this timeout I'm seeing just something that the browser does if it sees some Javascript that's kicking off every second and not producing any results? I didn't read about any kind of default timeout in the docs, and Google doesn't reveal anything useful.


That's a hell of a lot of AJAX calls without a decay option. I don't know how fast your server can respond, but I'm pretty sure that one open AJAX call/second is screwing something up. I would say at least add a decay of 2 or 3 and see what happens.

Also, are you sure that the log file is changing in the interval where you see a timeout?

Sock on a Fish
Jul 17, 2004

What if that thing I said?

sonic bed head posted:

That's a hell of a lot of AJAX calls without a decay option. I don't know how fast your server can respond, but I'm pretty sure that one open AJAX call/second is screwing something up. I would say at least add a decay of 2 or 3 and see what happens.

Also, are you sure that the log file is changing in the interval where you see a timeout?

I think the timeout occurs during a period when the log isn't being updated. The first step in the log reflects the beginning of a tarball unpack, and depending on load that can take from 1-12 minutes.

The server can respond to this load just fine. It's an internal app that at most 3-4 people are going to be using at once, and the cluster it's on handles thousands of requests per second.

sonic bed head
Dec 18, 2003

this is naturual, baby!

Sock on a Fish posted:

I think the timeout occurs during a period when the log isn't being updated. The first step in the log reflects the beginning of a tarball unpack, and depending on load that can take from 1-12 minutes.

The server can respond to this load just fine. It's an internal app that at most 3-4 people are going to be using at once, and the cluster it's on handles thousands of requests per second.

What do you mean by timeout? Is the div id "log" not changing? Are you getting a javascript error? Or are you falling into the failure side of the AJAX Request?

Roseo
Jun 1, 2000
Forum Veteran
Anyone have idea why this won't generate markers in an embedded Google Map under Chrome but works on every other browser I've tested it under? I know it can stand to be refactored, but I can't figure out why the gently caress this basic code doesn't generate my markers.


code:
var info = [ 'html', 'html', 'html' ];
var locs = [ '40', '-50', '42', '-51', '44', -56' ]; 

function drawmap() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map_canvas"));

    var id = 1;
    while (locs.length > 0) { // While the array is populated...
      var point = new GLatLng(locs.shift(), locs.shift()); //locs is array of alternating lats and longs, shift it twice to get the coords back.
      map.addOverlay(createMarker(point, id));
      id++;
    }
  }
}

function createMarker(point, id) {
  var towerIcon = new GIcon(baseIcon);
	
  var marker = new GMarker(point);
  marker.value = id;
  GEvent.addListener(marker, "click", function() {
    var html = info[id-1];
    map.openInfoWindowHtml(point, html);
  });
  return marker;
}

Roseo fucked around with this message at 01:57 on Apr 8, 2009

FateFree
Nov 14, 2003

I am a java developer primarily, and my knowledge of javascript is pretty limited. I've come into a requirement for a project that takes a giant chunk of html (mostly text, a few bold, italic, or underline tags, and images are possible), and instead of displaying it in one page with a long scrollbar, the requirement is to paginate it so that the viewers can click a navigation bar on the bottom (first, next, page 1, 2, 3, .. 10, last etc).

Initially, this requirement was only for a chunk of text, so server side my java code would count characters and lines and line breaks, and break the text into several page objects, which were easy to paginate. However it never felt right because it seemed like this was something a browser was meant to do, and now that html is possible, I can't run the same algorithm because I can't compute the size of the images and i'd have to strip out all the tags and whatnot.

Can you think of a way this may be accomplished with javascript, or should I try to do it with java still? One thing that may be an issue is if the browser will know when to break apart the text in order to paginate it correctly. Any ideas?

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH
Pagination is generally not done client side and is done server side(in your case, with Java).

sonic bed head
Dec 18, 2003

this is naturual, baby!
Does anyone know why 3rd party JS libraries never throw any errors? I just spent 4 hours today trying to figure out what I had done wrong after adding Jawr to my web app and the problem was that Nick Stakenburg's Starbox plugin doesn't throw an error when there's something wrong with the image url. It just completely silently fails and doesn't try to create anything.

I've seen this problem in Prototype, JQuery and ExtJS, even in the debug versions. A lot of problems could be solved much easier if informative errors were thrown. I do it in my own code, is this not a best practice?

Supervillin
Feb 6, 2005

Pillbug

sonic bed head posted:

Does anyone know why 3rd party JS libraries never throw any errors?

I noticed this too, and some library sites actually advertise that as a feature. I guess it increases market share among people who want just "plug and play (or don't play)" rather than actually writing try catch blocks when appropriate. I wish at least there were an option you could set before loading the library that would turn on/off "throw errors" mode.

Kekekela
Oct 28, 2004
JSLint gives me a "Bad escapement" message on the following line, I'm guessing its something with that which follows the backslash but I suck at regex and can't get it cleaned up, halp:

code:
var regex = new RegExp("(?=\.(xls|xlsx))");

sonic bed head
Dec 18, 2003

this is naturual, baby!

Kekekela posted:

JSLint gives me a "Bad escapement" message on the following line, I'm guessing its something with that which follows the backslash but I suck at regex and can't get it cleaned up, halp:

code:
var regex = new RegExp("(?=\.(xls|xlsx))");

Why on earth are you using the RegExp constructor? Why not...

code:
var regex = /(?=\.(xls|xlsx))/;
?

Kekekela
Oct 28, 2004

sonic bed head posted:

Why on earth are you using the RegExp constructor? Why not...

code:
var regex = /(?=\.(xls|xlsx))/;
?

Umm, I don't know, but I'm doing it your way now. :downs:

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Kekekela posted:

JSLint gives me a "Bad escapement" message on the following line, I'm guessing its something with that which follows the backslash but I suck at regex and can't get it cleaned up, halp:

code:
var regex = new RegExp("(?=\.(xls|xlsx))");

Have you tried the alternate syntax to see if that makes it shut up?

code:
var regex = /(?=\.(xls|xlsx))/;
edit: drat, beaten because I forgot to hit POST =(

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Kekekela posted:

JSLint gives me a "Bad escapement" message on the following line, I'm guessing its something with that which follows the backslash but I suck at regex and can't get it cleaned up, halp:

code:
var regex = new RegExp("(?=\.(xls|xlsx))");

People have explained how to use the regex /.../ syntax to fix this, but let me explain why it's happening real quick. What you're passing into the RegExp constructor isn't a regex, but rather a regular old string that represents a regex. So, you have to follow character escaping rules inside that string, and "\." isn't a valid escape sequence. You would have to say "\\." to get the correct result.

That's why using the /.../ sequence is better, because you're entering the regex verbatim instead of encoding it as a string, so the escaping rules don't apply and you can avoid the double-backslash nonsense that can get really messy.

Adbot
ADBOT LOVES YOU

The Wizard of Oz
Feb 7, 2004

I need to determine what the input focus is without touching any elements directly - so no onfocus injection. I also need to do this within an iframe which has arbitrary contents.

The only method I've been able to figure out so far is to inject a style element that has such a condition as:

code:
input:focus { unused: 666; }
Where unused can be anything that's not relevant to the control but is present. Then I window.getComputedStyle anything that seems appropriate and test for my property.

This works and should be portable but I wouldn't want to run it on a massive HTML file or one containing a huge number of focusable elements. AFAICT there is no standard solution. I've found the one that should be in Gecko, and now I mostly want to know if there's one for WebKit.

FateFree posted:

I am a java developer primarily, and my knowledge of javascript is pretty limited. I've come into a requirement for a project that takes a giant chunk of html (mostly text, a few bold, italic, or underline tags, and images are possible), and instead of displaying it in one page with a long scrollbar, the requirement is to paginate it so that the viewers can click a navigation bar on the bottom (first, next, page 1, 2, 3, .. 10, last etc).

Initially, this requirement was only for a chunk of text, so server side my java code would count characters and lines and line breaks, and break the text into several page objects, which were easy to paginate. However it never felt right because it seemed like this was something a browser was meant to do, and now that html is possible, I can't run the same algorithm because I can't compute the size of the images and i'd have to strip out all the tags and whatnot.

Can you think of a way this may be accomplished with javascript, or should I try to do it with java still? One thing that may be an issue is if the browser will know when to break apart the text in order to paginate it correctly. Any ideas?

You don't need to count characters/lines, just walk through at the document.body level testing node.getBoundingClientRect(). Once that exceeds a page, make a note to cut the document at that point and continue. When you've gathered all the pages together, blank the document if it's displayed, transfer nodes into your pages, and then show the first page.

This won't work for everything, and there can't be any general rule because the page could be dynamic or use CSS to break position order. But it'd be easy enough to chase the rabbit down the hole far enough to work for whatever it is you need.

That leads to a second question, is there any god-damned reason to be using offsetLeft/offsetTop/offsetParent when getBoundingClientRect does the same thing without a loop? I only started doing it because I had a page in Gecko flat-out fail when I tried the offset method, and AFAICT it always produces the correct result.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply