[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

FRAME SRC="about:blank" oddities

I'm using <FRAME NAME="menu" SRC="about:blank" >... to create blank frames to fill dynamically using JavaScript.

At run-time, however, after JavaScript writes to the frame, the frame then fills itself with the referrring document.

If you press "back" you notice that indeed, the frame was written to, but there's this wierd little bit of code at the top of the frame which might have something to do with why the frame does not "hold."

<base HREF="http://myserver.com/documentbasedirectory/">

Anyone know what is going on here?  Is there a work-around that does not use the "about:blank" framesource tag?

I'm using NS 3.01

Many thanks,

Anthony Krinsky
0
askrinsky
Asked:
askrinsky
  • 2
  • 2
1 Solution
 
garikCommented:
Hi Anthony,
The BASE tag is not related to "about:blank" - try set frame source to real HTML page and you'll still get <base href=...> as soon as you write to the frame. Must be something with document.write.
But you can always override BASE reference by the one you need.
As to the frame filling itself with the referring document, I couldn't reproduce it in NS 3.01 - could you post some code which shows the problem?
0
 
askrinskyAuthor Commented:
Hi Garrik --

Here's a snippet of my code.  Maybe it has something to do with the unescape() function that I'm using.

I'm mystified!

Anthony


<HTML><HEAD>
<SCRIPT language=javascript>
        pwin=window.open('','P');
        pwin.document.write('<FRAMESET COLS="100%" ROWS="59,*" noborder border="0">');
        pwin.document.write('<FRAME NAME="menu" SRC="about:blank" SCROLLING="NO" MARGINHEIGHT=0 MARGINWIDTH=0>');      
        pwin.document.write('<FRAME NAME="main" SRC="about:blank" SCROLLING="AUTO" MARGINHEIGHT=0 MARGINWIDTH=0>');
        pwin.document.write('</FRAMESET>');

        pwin.menu.document.close();
        pwin.menu.document.open();
        pwin.menu.document.write(unescape(document.preview_html.menu_preview.value));
        pwin.menu.document.close();
</script>
</HEAD>
<BODY>
<FORM name=preview_html>
<INPUT TYPE=HIDDEN NAME=menu_preview value="%3Chtml%3E%3Chead%3E%0A%3Cmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3Diso-8859-1%22%3E%0A%3Ctitle%3EIDAs%2FUSAs%20Proxy%20Menu%20Preview%3C%2Ftitle%3E%0A%3Cbody%20bgcolor%3D%22%23333399%22%20background%3D%22..%2F..%2Fmenus%2Fmenu_images%2Fm_id_bkgrnd.gif%22%20leftmargin%3D0%20topmargin%3D0%3E%0A%3Cp%3E%0A%3CCENTER%3E%3CFORM%3E%3CINPUT%20TYPE%3DBUTTON%20NAME%3Doksave%20VALUE%3D%22%20%20%20%20%20%20%20%20SAVE%20%20%20%20%20%20%20%20%22%20OnClick%28%29%3D%22self.parent.opener.SaveDoc%28%29%3B%22%3E%20%3CINPUT%20TYPE%3DBUTTON%20NAME%3Dcancel%20VALUE%3D%22BACK%20TO%20BUILDER%22%20OnClick%28%29%3D%22self.parent.close%28%29%3B%22%3E%3C%2FFORM%3E%0A%0A%3C%2Fbody%3E%3C%2Fhtml%3E%0A"><br></FORM>
</BODY></HTML>
0
 
garikCommented:
To make it work, I'd to do two things:
1) put document.writes to onLoad handler and pass it the value of the hidden field
2) remove META tag from this value
While the first step doesn't affect logic too much, second might be crucial for your application. Right now I've no idea why META causes reloading.
Working code is below.

<HTML><HEAD>
<SCRIPT language=javascript>
function fill(doc) {
      pwin=window.open('','P');
      pwin.document.write('<FRAMESET COLS="100%" ROWS="59,*" noborder border="0">');
      pwin.document.write('<FRAME NAME="menu" SRC="about:blank" SCROLLING="NO" MARGINHEIGHT=0 MARGINWIDTH=0>');      
      pwin.document.write('<FRAME NAME="main" SRC="about:blank" SCROLLING="AUTO" MARGINHEIGHT=0 MARGINWIDTH=0>');
      pwin.document.write('</FRAMESET>');
      pwin.menu.document.close();
      pwin.menu.document.open();
      pwin.menu.document.write(unescape(doc));
        pwin.menu.document.close();
}
</script>
</HEAD>
<BODY onLoad='fill(document.preview_html.menu_preview.value);'>
<FORM name=preview_html>
<INPUT TYPE=HIDDEN NAME=menu_preview value="%3Chtml%3E%3Chead%3E%0A%3Ctitle%3EIDAs%2FUSAs%20Proxy%20Menu%20Preview%3C%2Ftitle%3E%0A%3Cbody%20bgcolor%3D%22%23333399%22%20background%3D%22..%2F..%2Fmenus%2Fmenu_images%2Fm_id_bkgrnd.gif%22%20leftmargin%3D0%20topmargin%3D0%3E%0A%3Cp%3E%0A%3CCENTER%3E%3CFORM%3E%3CINPUT%20TYPE%3DBUTTON%20NAME%3Doksave%20VALUE%3D%22%20%20%20%20%20%20%20%20SAVE%20%20%20%20%20%20%20%20%22%20OnClick%28%29%3D%22self.parent.opener.SaveDoc%28%29%3B%22%3E%20%3CINPUT%20TYPE%3DBUTTON%20NAME%3Dcancel%20VALUE%3D%22BACK%20TO%20BUILDER%22%20OnClick%28%29%3D%22self.parent.close%28%29%3B%22%3E%3C%2FFORM%3E%0A%0A%3C%2Fbody%3E%3C%2Fhtml%3E%0A"><br></FORM>
</BODY></HTML>

0
 
askrinskyAuthor Commented:
Thanks Garik! For a moment, I've abandoned javascript here for perl.  I'll tell you what happens when I try again with javascript using your recommendations.  AK.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now