Advertisement

09.29.2008 at 01:20PM PDT, ID: 23772783 | Points: 500
[x]
Attachment Details

How Do I Dynamically Write a Script to a Div and Immediately Execute It?

Asked by JaeWebb in JavaScript, Dynamic HTML (DHTML), Asynchronous Javascript and XML (AJAX)

Tags: ,

I have an HTTP address that points to a remote script.  The result of the script is a hyperlink with a 1x1 pixel GIF inside it.  So far I have been able to get the script to appear inside a specifically targeted div.  What I want is for the script to execute as soon as it appears in the div, like this...


<scr'+'ipt language="JavaScript" type="text/javascript" src="http://oascentral.law.com/RealMedia/ads/adstream_jx.ads/interstitial.law.com/testing/@x96"></scr'+'ipt>

...accept without the redirect.  I need the page to stay where it is and I need the script result to appear in the targeted div.

This is where I got the idea that I'm working on: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23023005.html

My code is below:


Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
function adTagCall()
 
{
 
	flashPlayer = window.document.FLVAdPlayer;
 
	var hiddenDataDiv = document.getElementById( "FLVAdPlayer_Hidden" )
 
	var newScript = document.createElement('script');
 
	newScript.type = 'text/javascript';
 
	newScript.src = 'http://oasc10.247realmedia.com/RealMedia/ads/adstream_sx.ads/nylj.com/@x47';
 
	hiddenDataDiv.appendChild( newScript );
 
	
	//THIS TAG BELOW IS WHAT I'M TRYING TO DO (WITHOUT REDIRECTING THE PAGE)
	//<scr'+'ipt language="JavaScript" type="text/javascript" src="http://oascentral.law.com/RealMedia/ads/adstream_jx.ads/interstitial.law.com/testing/@x96"></scr'+'ipt>
 
}
 
Loading Advertisement...
 
[+][-]09.29.2008 at 01:41PM PDT, ID: 22600468

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.29.2008 at 02:47PM PDT, ID: 22601062

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.29.2008 at 02:50PM PDT, ID: 22601074

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628