Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Actions based off of specific pages (in frames)

    Ok this is a complicated one but I'll try my best to explain it. I have a framset document; one of the frames contains timers which I would like to have reset when another frame (the "main" frame) visits a certain page. The timer reset code is
    Code:
    javascript:maReset(1)
    but I know I will need to add to that.

  • #2
    Regular Coder
    Join Date
    Jul 2007
    Location
    UK
    Posts
    223
    Thanks
    0
    Thanked 14 Times in 14 Posts
    I think you'll need to periodically check the location.href of the "main" frame then when you get a match you can reset the timer.

    To reference the "main" frame you'll have to use something like:
    Code:
     
    parent.main.location.href
    Or,
    If the "certain page" that triggers the reset is one of yours you can reset the timer in another frame from that page. You have to reference the timer correctly though.
    For example if your frame the timer exists in is called "timerFrame" and the timer reference is called "timer" you could put the following in a function that runs onload (also assuming you're using setTimeout to start the timer not setInterval otherwise you'd need clearInterval instead of clearTimeout):
    Code:
    if(parent.timerFrame.timer){
      parent.timerFrame.clearTimeout(parent.timerFrame.timer);
    }

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts

    Same origin policy

    If the page in the main frame is not in the same domain as yours, then you can't access that frame eventhough you only want to get the url.

  • #4
    New Coder
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    6
    Thanked 0 Times in 0 Posts
    The page in the "main" frame is not mine so I cant put any code on it. glenngv are you saying then that this wont work at all or will I be able to use the
    Code:
    parent.main.location.href
    as mcjwb said?


  •  

    Posting Permissions

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