We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

FRAME SRC="about:blank" oddities

askrinsky
askrinsky asked
on
Medium Priority
371 Views
Last Modified: 2008-03-17
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
Comment
Watch Question

Commented:
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?

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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>

Commented:
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>

Author

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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.