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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Delay execution of 2nd half...

    Hi!

    I can muddle through JS but I'm no pro...

    Below is frames() a dynamic frameset script for visitors hitting my internal pages out-of-frames. Works just fine but writes the frameset too quick, visitors can't back-out. I simply want to show a message "You are out of frames buddy" and give a polite 2 second pause before writing the frameset.

    So I'm calling detect() from the body tag to doc.write a message and pause before calling "frames()". My message is getting onscreen but function frames() won't function! If I delete my document.write message then it all works just fine?!? What on Earth am I doing wrong?

    Many thanx in advance...

    <script language="JavaScript">
    <!--
    function detect() {
    if (top.frames.length==0) {
    document.write('<font size="2" color="crimson" face="verdana,helvetica,sans-serif"><b>out of frames</b></font><br>');
    document.write('<font size="1" color="black" face="verdana,helvetica,sans-serif">loading frameset...</font>');
    timer=setTimeout('frames()',2000) }
    }

    function frames() {
    framesetpage="awnings-frameset.html";
    thispage=window.location.href;
    if (thispage.indexOf('://')<0) {thispage="://"+thispage;};
    prefix=thispage.substring(0,thispage.lastIndexOf('://'));
    suffix=thispage.substring(thispage.lastIndexOf('://')+3,thispage.length);
    // alert('the subpage is:['+prefix+']['+suffix+']');
    if (parent.location.href==window.location.href) {parent.location.href=framesetpage+"?"+prefix+"&&&"+suffix};
    }
    // -->
    </script>

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you're calling detect from the body tag that means you must be using the onload event. That also means that document.write replaces the current document with the new document written by your document.write statements so the delayed function never executes. You need to try putting the call to detect as the last thing before the </body> tag instead.
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  

    Posting Permissions

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