Results 1 to 3 of 3

Thread: JavaScript not running in external pages on Ajax Tabs Content script

  1. #1
    Join Date
    Jan 2008
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default JavaScript not running in external pages on Ajax Tabs Content script

    1) Script Title: Ajax Tabs Content script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tent/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,
    Last edited by dogshasha; 07-11-2012 at 07:16 PM.

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,875
    Thanks
    49
    Thanked 263 Times in 255 Posts
    Blog Entries
    56

    Default

    Ajax does not bring in (by itself) external javascript. That's the nasty thing about it.
    Arie Molendijk.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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):

    Code:
    <script type="text/javascript">
    
     var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
     countries.setpersist(true)
     countries.setselectedClassTarget("link") //"link" or "linkparent"
     countries.init()
    
     countries.onajaxpageload = function(pageurl){
    	 if (pageurl.indexOf("external4.htm") != -1){
    		alert('Hello');
    	 }
     };
    
     </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •