View Full Version : JavaScript not running in external pages on Ajax Tabs Content script

07-11-2012, 07:06 PM
1) Script Title: Ajax Tabs Content script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm

3) Describe problem: In the demo, if I add a JavaScript <script>alert("hello")</script> in external4.htm, it doesn't run when I click on "Tab 4". Is there any way to allow javascript to run? Thanks,

07-11-2012, 10:20 PM
Ajax does not bring in (by itself) external javascript. That's the nasty thing about it.
Arie Molendijk.

07-14-2012, 03:16 PM
Which scripts are those?

Anyways, if content on a page is changed and the load event for the page has passed, often a script will stop functioning.

This need not be.

Many scripts are written to look for all elements that fit certain criteria and assign click and/or hover events to them.

If instead these scripts listened to the page for click and/or hover events and reacted to them if the trigger element fit those criteria, then new content would work without having to be initialized.

Or, after new content arrives, it can be initialized. That's one of the things that instance.onajaxpageload can be used for (example using the alert):

<script type="text/javascript">

var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
countries.setselectedClassTarget("link") //"link" or "linkparent"

countries.onajaxpageload = function(pageurl){
if (pageurl.indexOf("external4.htm") != -1){