• Alert needed to make code work

    Author
    Topic
    #428497

    Hi

    I wrote the following code to force a page intended for frames into its frameset:

    function ForceIntoFrames(MyLevelPrefix) {
    	if (top == self) {
    		var MyURL;
    		MyURL=document.URL;
    		top.location.href = MyLevelPrefix + "default.htm";
    		/* @@@ For some reason, this doesn't work without the alert??? @@@ */
    		alert("Click OK to display the page");
        		sjBody.location=MyURL;
    	}
    }

    It works okay, but not if I remove the alert. Instead, it processes “top.location.href”, displays the default.htm, then stops.
    Added later: sjBody is the name of the target frame.

    Any ideas? I don’t have too much experience with JavaScript, so I may be missing something obvious. Or maybe it’s some sort of timing issue?

    Thanks
    Dale

    Viewing 0 reply threads
    Author
    Replies
    • #995688

      Hi Dale

      I am not a javascripter as such as I only dabble but I have found this link:

      jwweb

      and

      webmasterworld

      They both seem to be talking through the same method, could this help you?

      • #996139

        Thanks, Jerry. Those references were very helpful.

        Actually, I think I may just have changed my mind about frames. I like them because they provide an easy way of keeping the navigation in view, even when the user pages down. The big negative, of course, is that bookmarking effectively doesn’t work when you use frames.

        However, I’ve now discovered that

        s can be positioned dynamically (I must have been sleeping when the news came out). I haven’t found any example code, yet, but it must be possible to put the navigation in a

        and dynamically keep the

        visible. I presume you would use the onkeyup event (or similar) to trigger the movement.

        Mmmm, interesting.

        Thanks again
        Dale

        • #1000840

          The CSS spec provides for a “fixed” position div and a scrolling one right beside it. IE apparently does not support this completely, so there are some “hacks” that might be needed to make it work. I’m experimenting with a set of stylesheets for a wiki; you can download them from the source at PmWiki – Cookbook – FixFlowSkin. (In that example, of course, the navigation is too long, but if you customize it for your own site, it should be fine.)

          Added: By the way, regarding the alert, it could be a timing issue: the target document might not be completely loaded, so the code can’t run properly yet. You could try using setTimeout() (apologies for any case errors, I did not look it up) to schedule the code to run a few milliseconds in the future and see whether that helps.

    Viewing 0 reply threads
    Reply To: Alert needed to make code work

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: