http://qs321.pair.com?node_id=224313

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Not sure if this a perl thing or JavaScript thing .... I apologize for my incompetence. Anyways here's the scenario - I have a page with two frames, a left frame and right frame where a perl script throws out all the HTML code for both these frames. Now the problem is that when the code throws out a <href> in the left frame, which on clicking opens a page in the right frame; on clicking the link, the right frame does change, but the left frame showings a loading bar in IE i.e. the blue bar on the bottom of the browser (IE) which shows that the page is still loading. My code looks something like this -
(Left Frame)
<a href=javascript:JSGotoRightFrame('/cgi-bin/dynamicScheduler.pl?task +=getClassInfo&uid=$uid&classid=$temp');>$subject $classnumber</a>
Any ideas? I have this problem on more than one page and am 100% sure it is not a looping script or something. If I pass another function inside this href which reloads the left frame with the same content, the bar disappears. Thanks.

Replies are listed 'Best First'.
Re: Perl + Frames + JavaScript
by tachyon (Chancellor) on Jan 05, 2003 at 12:27 UTC

    You don't need javascript to do this. A CGI can have its output targeted to a frame using the header you print like this:

    use CGI; my $q = new CGI; print $q->header(-target=>'ResultsWindow'); # or roll your own header like this print "Window-Target: ResultsWindow Content-Type: text/html\n\n";

    So all you need it a link to the script like

    <a href="/cgi-bin/script.pl?target=SomeFrame&other=stuff">Click Here</ +a> # and in the script my $target = $q->param('target'); print $q->header(-target => $target );

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: (nrd) Perl + Frames + JavaScript
by newrisedesigns (Curate) on Jan 04, 2003 at 22:08 UTC

    My JavaScript is a little rusty, but try adding "return true;" to the end of your javascript: line.

    <a href="javascript:JSGotoRightFrame('/cgi-bin/dynamicScheduler.pl?tas +k=getClassInfo&uid=$uid&classid=$temp'); return true;">$subject $clas +snumber</a>

    If this works, let us know. If not, I'll go and dust off my JS book and take a look for you. (Also, you should use="quotes" to set an attribute such as HREF in an anchor tag. It's better HTML that way, and is a start on the path of monkly righteousness.)

    John J Reiser
    newrisedesigns.com

      John, Thanks for the update (and tips), but unfortunately it doesn't work. It prints "true" on the left frame while going to the link on the right frame. Any ideas? Thanks.

        See tachyon's post below. I completely forgot that you an redirect with CGI. That method is much more reliable (some people don't browse with JavaScript on) and allows you to work in Perl (which is ++ if you are more accustomed to Perl.)

        I looked on JavaScript.com, which is a pretty good resource for JS, and found this, if you want to stick with JavaScript.

        John J Reiser
        newrisedesigns.com

Re: Perl + Frames + JavaScript
by oknow (Chaplain) on Jan 05, 2003 at 17:38 UTC
    I might be missing something, but wouldn't it be easier to skip the javascript and use the target attribute on the anchor tag?
    <a href="/cgi-bin/dynamicScheduler.pl?task+=getClassInfo&uid=$uid&clas +sid=$temp" target="RightFrameName">$subject $classnumber</a>
      People, Thanks a lot for all your help...... really appreciate it! OKNOW, thanks a ton ..... I don't know why I didn't try that before .... I knew it but it just didn't come to me when I needed it (grin) .... I guess that happens sometimes! Anyways thanks and have a great new year. S