[thelist] javascript/frame problem

Seb Barre sebastien at oven.com
Fri Oct 27 13:41:09 CDT 2000


At 02:25 PM 10/27/2000 -0400, you wrote:
>Hi all-
>
>The site is a frameset with two frames: frame_left and frame_right.
>frame_left contains navigation and frame_right contains content.
>
>Initially, the site displays a set of news articles in frame_right.
>frame_left has a search form which is submitted by means of javascript:
>
><a
>href="javascript:parent.frame_left.document.frmSearch.hAction.value=2;parent
>.frame_left.document.frmSearch.submit();" target="frame_right"
>onMouseOver='javascript:fontOn(this);' onMouseOut='javascript:fontOff
>(this);'>Symbol</a>
>
>The form in question is:
>
><form name="frmSearch" action="/News/news.asp" target="frame_right"
>method="post">
>
>The news articles are located on a different server than the inital
>frameset and frame pages (newsiis.xxx.com vs. wwwbeta.xxx.com). The search
>function works as long as the user is not viewing an actual article. As
>soon as an article is loaded into frame_right from the other server, the
>search stops working, and instead, the browser attempts to load the file
>named:
>
>javascript:parent.frame_left.document.frmSearch.hAction.value=2;parent.frame
>_left.document.frmSearch.submit();
>
>which of course leads to a freaky error.
>
>Can any of you all suggest why the javascript: protocol stops working when
>an article is loaded into the content frame?

This has to do with the scripting security model in browsers.  As soon as 
the content in the right frame comes from a different server than the root 
page and/or the other frame, Javascript calls in your left frame can't 
access anything in the right frame.  This is to stop someone from "framing" 
your site and using Javascript to redirect form submissions and/or modify 
the functionality of your site without your (or the surfer's) knowledge.

Your best bet would be to have the form in the left hand nav (you can 
easily keep it hidden) and just have it target the right frame when it 
submits, as opposed to having Javascript call the form submit on the form 
located in the right-side frame..

Let me know if I'm not explaining myself properly. =)


--- -- -
Seb Barre - sebastien at oven.com
OVEN Digital Toronto
Work: 416-595-9750 x 222
Mobile: 416-254-5078
http://www.oven.com/





More information about the thelist mailing list