![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
quote You are obsessed! Just curious but when is it that you are wanting to do script insertion with totally random scripts you haven't written yourself or written by a coworker? Just academic interest? /quote For myself I am trying to write code that asynchronously injects adverts into a web page. You'll notice across the web millions of sites whose pages might be quite fast-loading in themselves, but with 3 or 4 massive delays as the page goes to ads.domain.com to fetch the ad code, which characteristically is a mix of javascript and html, and is generated by 3rd party software. I want this external data injected in the background, after the main page has finished rendering, for an improved user experience. Make sense? |
#12
| |||
| |||
|
#13
| |||
| |||
|
|
Hi Peter, quote What about just inserting an iframe into the page and setting the src attribute to a URL that produces the ads? Because of iframes, it isn't a valid approach for HTML strict pages but is on HTML transitional. /quote That's probably where I'll end up. For reasons I can't remember now I started trying to do this the .js way, and I'm stupidly determined to try to get it to work. Though in fact I am going for HTML strict too <sigh>. |
#14
| |||
| |||
|
|
For myself I am trying to write code that asynchronously injects adverts into a web page. You'll notice across the web millions of sites whose pages might be quite fast-loading in themselves, but with 3 or 4 massive delays as the page goes to ads.domain.com to fetch the ad code, which characteristically is a mix of javascript and html, and is generated by 3rd party software. I want this external data injected in the background, after the main page has finished rendering, for an improved user experience. Make sense? |
#15
| |||
| |||
|
|
quote You are obsessed! Just curious but when is it that you are wanting to do script insertion with totally random scripts you haven't written yourself or written by a coworker? Just academic interest? /quote For myself I am trying to write code that asynchronously injects adverts into a web page. You'll notice across the web millions of sites whose pages might be quite fast-loading in themselves, but with 3 or 4 massive delays as the page goes to ads.domain.com to fetch the ad code, which characteristically is a mix of javascript and html, and is generated by 3rd party software. |
|
I want this external data injected in the background, after the main page has finished rendering, for an improved user experience. Make sense? |
#16
| |||
| |||
|
|
I want this external data injected in the background, after the main page has finished rendering, for an improved user experience. Make sense? Put an IFrame on the page that has a secondary page in it that loads the ad. It will make your life simpler and save you a lot of sleepless nights. |
#17
| |||
| |||
|
|
Randy Webb said the following on 8/20/2007 8:46 PM: I have revised that function to accommodate NN6.1/NN6.2Win and hopefully it will accommodate the innerHTML mac browsers (iCab and IE). If anyone could test it on a non-windows browser I would be grateful. |
|
Added was the innerHTML testing so that browsers that execute innerHTML scripts wouldn't execute them twice. var innerHTMLFailed=true; window.onload = checkIt; function checkIt(){ document.getElementById('myDiv').innerHTML = '<script type="text/javascript">var innerHTMLFailed = false;<\/script>'} function loadHTMLFragment(elemId, HTMLFragment) { if (document && document.getElementById && document.getElementById(elemId) && document.createElement && document.appendChild && document.getElementsByTagName && { var el = document.getElementById(elemId); el.innerHTML = " " + HTMLFragment; //The is a hack to cause IE to process the //script elements if the first node in the //HTMLFragment is a script element. if(innerHTMLFailed) { var d =el.getElementsByTagName('script'); var t = d.length; for (var x=0;x<t;x++) { var newScript = document.createElement('script'); newScript.type = "text/javascript"; newScript.text = d[x].text; el.appendChild(newScript); } for (var y=0;y<t;y++) { el.removeChild(el.getElementsByTagName("script")[y]); } } } } Next step is a test of the .text attribute since I know of browsers that do not support setting the .text property of a newScript element. |
#18
| |||
| |||
|
|
On Aug 22, 7:01 am, Randy Webb <HikksNotAtH... (AT) aol (DOT) com> wrote: I want this external data injected in the background, after the main page has finished rendering, for an improved user experience. Make sense? Put an IFrame on the page that has a secondary page in it that loads the ad. It will make your life simpler and save you a lot of sleepless nights. Agreed, use an iframe and save yourself from a "world of pain." |
#19
| |||
| |||
|
|
On Aug 20, 8:52 pm, Randy Webb <HikksNotAtH... (AT) aol (DOT) com> wrote: Randy Webb said the following on 8/20/2007 8:46 PM: I have revised that function to accommodate NN6.1/NN6.2Win and hopefully it will accommodate the innerHTML mac browsers (iCab and IE). If anyone could test it on a non-windows browser I would be grateful. Have you posted a test page? I'll click some buttons for you and send you the results. |
#20
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |