homepage Welcome to WebmasterWorld Guest from 54.166.100.8
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Browsers / Opera Browser Usage and Support
Forum Library, Charter, Moderator: open

Opera Browser Usage and Support Forum

    
Reframing in Opera
code to put frame into its framed context crashes Opera 6
ShawnR




msg:1584624
 3:54 pm on Apr 3, 2003 (gmt 0)

Hi

I would like to put a frame into its framed context if it is called up without its frame (e.g. from a search engine result). The following is a cut-down extract of the code I am using. It works great in IE and Netscape, but causes Opera to crash.

In reframing.js:

function CheckInFrame(whichFrame, HomepageURL) {
if (top.location == self.location) {
subframe = document.location.href;
alert('Debug: about to set homepage to ' + HomepageURL + '?' + whichFrame + '=' + subframe);
self.location.replace(HomepageURL + '?' + whichFrame + '=' + subframe);
}
alert('Debug: finished checking we are in frame context');
}

function PopulateFrames() {
alert ('Debug: arrived');
originalURL = document.location.href;
contentTarget = originalURL.substring(originalURL.indexOf('?')+1, originalURL.indexOf('='));
contentURL = originalURL.substring(originalURL.indexOf('=')+1, originalURL.length);
if (window.top.frames[contentTarget]) {
window.top.frames[contentTarget].location.replace(contentURL);
}
}

In the main framed index file:
<script language="Javascript">
<!--
onload = function(){PopulateFrames()};
-->
</script>

In one of the frame files:
<script language="Javascript">
<!--
onload = function(){CheckInFrame('left_nav', '../index.html')};
-->
</script>

In NN & IE it works great. In Opera, when I open the index file, it is fine. However, when I open a sub-frame page, it executes the first debug statement (alert('Debug: about to set homepage...), but never gets to the alert('Debug: finished checking... ) (which may not be surprising), and never gets to the alert('Debug: arrived').

I have tried href = contentURL instead of replace(contentURL) but that did not help. I also tried document.URL instead of document.location.href, but that didn't help Opera, and didn't work well in IE.

thanks in advance
Shawn

PS. Pls, no advise to deframe/flatten the site. That is a very debatable topic, but probably shouldn't be debated in this thread ;-) I'd really prefer help with why the javascript isn't working rather than the pros/cons of frames.

 

SinclairUser




msg:1584625
 4:20 pm on Apr 3, 2003 (gmt 0)

Opera is known to be a buggy browser and some developers will not support it.

I guess you need to decide if it is worth the hassle to make changes to your design to "accommodate" a defective browser.

Chris.

tedster




msg:1584626
 6:57 pm on Apr 3, 2003 (gmt 0)

You can try using the javascript console in Opera to get a more precise error message - There's a checkbox at Preferences > Multimedia to open the console onError.

That looks like pretty basic javascript - Opera certainly should support it.

ShawnR




msg:1584627
 10:33 pm on Apr 3, 2003 (gmt 0)

Thanks guys

I don't like the idea of not supporting Opera; it is pretty popular.

I have selected the option to report Javascript errors, but I don't get any. It looks like an infinite loop with the browser window being constantly refreshed, rather than a Javascript error.

Any other ideas? Is there a Javascript debugger for Opera, where I could put a watch on variables or define breakpoints?

Shawn

ShawnR




msg:1584628
 3:08 am on Apr 4, 2003 (gmt 0)

The problem was that Opera (V6) didn't like the '/' character anywhere after the '?' in its href. To solve it I had to:


subframe = subframe.replace(new RegExp('/', 'g'), '&#47;');

in the CheckInFrame function, and then do the inverse in the PopulateFrames function.

Just for good measure, I also did

subframe = escape(subframe);

and unescape() in PopulateFrames() (although unescaped chars were not the problem in this case).

Anyone seen this before and/or have a more elegant solution?

Shawn

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Browsers / Opera Browser Usage and Support
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved