Javascript is available throughout the process, although some references are not available, but you can avoid those calls. If you manage to pack your document into a
JS variable, avoiding newline characters that destroy the string, and using only one type of quotes within the document, then you can access the page data. However your server has to queue Browser output until the page is complete.
<p>Suppose the final Server output is X, encapsulate it in JavaScript, making more output JS(X), subsequently the total output is JS(X) plus X, which means you will transmit twice the regular page length.
Javascript is available throughout the process, although some references are not available, but you can avoid those calls. If you manage to pack your document into a
JS variable, avoiding newline characters that destroy the string, and using only one type of quotes within the document, then you can access the page data. However your server has to queue Browser output until the page is complete.
<p>Suppose the final Server output is X, encapsulate it in JavaScript, making more output JS(X), subsequently the total output is JS(X) plus X, which means you will transmit twice the regular page length.
yes thats a solution but not the best one , i have also think about to make a ajax request to window.location but i hope we find a better way like document.getRawSource()
Javascript is available throughout the process, although some references are not available, but you can avoid those calls. If you manage to pack your document into a
JS variable, avoiding newline characters that destroy the string, and using only one type of quotes within the document, then you can access the page data. However your server has to queue Browser output until the page is complete.
<p>Suppose the final Server output is X, encapsulate it in JavaScript, making more output JS(X), subsequently the total output is JS(X) plus X, which means you will transmit twice the regular page length.
Definition of Newline
Code:
X = "Hello, this is a variable
that is not a valid string as its
on three lines, containing a new lines.";
Y = "Hello, this is a variable \r\nthat is a valid string as its\r\non three lines, containing the new line. characters";
Quotes...
Code:
a = "\"This is Valid\"";
b = "'This is also Valid'";
c = '\'This is valid also\'';
As long as you watching your quotes, they do not present a problem and where you have to use either a single or double quote with a back slash if you need to include it.
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
JunkMale, I agree with you 100% and more. However when assigning a JavaScript string like var YES ="text in here" or var NO = 'text in here', if text-in-there contain similar quotes as its encapsulation, then you arrive at broken strings at the browser level. However if text-in-there was recoded with backslashed quotes, then either quoting system could be used, and the 2nd text woukd have to be decoded at the browser level.
Broken strings only crop up because of poor programming and attention to detail.
The idea is to code in such a way that you do not need the \ at all and only when needed.
Escaping strings is nothing new neither is encapsulation.
The choice is really down to the application needs and not the programmers preferences, although coding is a personal choice of style and format, people generally sit with what they know or are comfortable with.
Your concerns of broken strings is over come by proper encapsulation and escaping where needed.
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
eh dudes the discussion goes in the wrong direction i cant put the html code into a js var because the script is a standalone script. it means i want to use the code on different webpages without great backend that can fill the js var
The question is raised to "Why do you need the current page in a JS var?" the whole DOM is readily available to any script that runs in the browser, packing a page in to a variable is pretty pointless thing to do.
It eats more resources than are really required, the memory is used also and I see no real justification for stuffing a variable with HTML, I can understand grabbing values out of the DOM and storing them of later use, but no reason I can conjure up as to the reason why the whole page needs to be in a variable.
Your comment about a standalone script, sorry, no such thing, that is compiled languages and javascript is interpreted, big difference.
It might help if you explain what the reason is for your need to have the page replicated in a JS variable. It may highlight an easier alternative to what your trying to achieve.
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
we are in the world of advertisement, i build for a client a google adsense script, this script need to know how many targets the webpages has.
normally its a simple part, wait for dom ready, select all targets, count them, request advertisements.
now we can't wait for dom ready because of performance issues, the script have a small "do..while" that waits for the (hardcoded dom-ids) elements. if its present then add the advertisement to the element (this happens all before dom ready, so its much faster!)
the problem is if the webpage have different targets, at page load we have 5 targets and after a reload we have only 3 or less… at this moment i have no informations about how many targets i have, i can't count them.
so my idea was to read the raw source code and explode all my target elements and count them there
(puh hard work in english i hope all can understand my crazy school english ^^)
You don't need a variable to do what you need to do. Yes you will have to wait for the dom to become ready.
Performance issues are generally down to poor implementation and often poor coding, routines that are resource hungry and by the description of the do{}while wait, that is certainly an indication of poor code, if you nned to wait for the DOM to become ready, you either use the onload listener in the HTML body tag or apply a window.onload listener that does the same thing and that is used to run your scrip when the dom is ready.
any "ugly" elements should be masked by css hide if your using targets in a web page.
We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
Code:
Youre = {
STILL_not_getting_it:function(){
alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
},
MissingThePoint:function(msg){
alert("You're missing the point. " + msg);
}
}
Youre.STILL_not_getting_it();
Bookmarks