Welcome to WebmasterWorld Guest from 54.167.157.247

Forum Moderators: open

Message Too Old, No Replies

Reframing in Opera

code to put frame into its framed context crashes Opera 6

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

WebmasterWorld Senior Member 10+ Year Member



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.

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

10+ Year Member



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.

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

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.

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

WebmasterWorld Senior Member 10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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