473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Weird Opera bug?

I'm working on a website that nests framesets within other framesets.
I want a click in one top-level frame to show/hide a menu in a second
level frame. Hete's a code fragment:

var cousin2_doc = brother_frameset['main-main'].document
var d = cousin2_doc

d.wp = function( obj ) { this.write( obj + '<p>' ) }
alert( d + ', ' + d.wp )

d.wp( 23 )
alert( d + ', ' + d.wp )

At the first alert(), we're happy. The second alert shows that the
function is gone. I'm using KDE on Linux. Konqueror doesn't have any
problem with this. Any ideas for a workaround?

The just-started project is at http://www.MartinRinehart.com/08 - the
offending piece is in main/lower-left.html.
Jul 1 '08 #1
9 1215
Ma************@gmail.com wrote:
I'm working on a website that nests framesets within other framesets.
Framesets are already a bad idea as they are often not needed. Nesting them
makes it only worse.
I want a click in one top-level frame to show/hide a menu in a second
level frame. Hete's a code fragment:

var cousin2_doc = brother_frameset['main-main'].document
var d = cousin2_doc

d.wp = function( obj ) { this.write( obj + '<p>' ) }
alert( d + ', ' + d.wp )

d.wp( 23 )
alert( d + ', ' + d.wp )

At the first alert(), we're happy. The second alert shows that the
function is gone. I'm using KDE on Linux. Konqueror doesn't have any
problem with this.
The created Function object is _not_ gone (at least not garbage-collected at
once), but the test shows that you could not augment the Document host
object with a property, which is not surprising. Host objects do not need
to support (arbitrary) augmentation, and it is up to their implementors to
define to what extent augmentation is possible.
Any ideas for a workaround?
More for a *fix*, remove `.document', and use `document' instead of `this'
in the method. If anything, functions of a global execution context are
methods of the Global/Window Object of this context, not its Document
object. That said, you should not expect it to be possible to define global
methods this way as Window objects are host objects, too.

You should end all these lines with a semicolon so as not to rely
on automatic semicolon insertion and the side-effects this can have.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jul 1 '08 #2
Framesets are already a bad idea as they are often not needed. Nesting them
makes it only worse.
I love my nested framesets. They help make pages dynamic. Try

http://www.ClintonBushCharts.com

In "Our Charts" you're looking at nested framesets. If you start with
GDP you
see the regular effect. Then on to Receipts or Expenses and you see
the nested
menu split into a top and bottom portion. Really gets the job done
well.

The created Function object is _not_ gone (at least not garbage-collected at
once), but the test shows that you could not augment the Document host
object with a property, which is not surprising. Host objects do not need
to support (arbitrary) augmentation, and it is up to their implementors to
define to what extent augmentation is possible.
Hmmm. Don't know about garbage collection, but if my last reference is
gone
to me it's gone. The problem is that at the first alert the object is
shown as
augmented, the call that prints 23 works, and then, after one use,
the
attribute disappears.
You should end all these lines with a semicolon so as not to rely
on automatic semicolon insertion and the side-effects this can have.
In Python, ending every line with a semi is a possibility, but no one
ever
does. You'd be laughed at. I googled this and it's universally
prescribed
as best practice in Javascript, but none of the reasons were
persuasive.
What is this "automatic semi insertion and the side effects"?
Jul 2 '08 #3
On Jul 1, 9:23 pm, Thomas 'PointedEars' Lahn wrote:
MartinRineh...@gmail.com wrote:
<snip>
> d.wp = function( obj ) { this.write( obj + '<p>' ) }
alert( d + ', ' + d.wp )
> d.wp( 23 )
alert( d + ', ' + d.wp )
>At the first alert(), we're happy. The second alert shows
that the function is gone. I'm using KDE on Linux. Konqueror
doesn't have any problem with this.

The created Function object is _not_ gone (at least not
garbage-collected at once), but the test shows that you could
not augment the Document host object with a property, which
is not surprising. Host objects do not need to support
(arbitrary) augmentation, and it is up to their implementors
to define to what extent augmentation is possible.
<snip>

Wouldn't the symptoms of a failure to augment a host object be an
'undefined' appearing in the first alert, followed by an exception
being thrown at the - d.wp( 23 ) - line?

The symptoms described are the first alert showing evidence of a
function, the call to that function (as a method of a document)
executing successfully and the final alert indicating the (now)
missing document method. I would suspect that the culprit is the line
- this.write( obj + '<p>' ) - inside the method, as that is
effectively a - document.write - call and that will (if the pertinent
document has finished loading) clear the existing document and replace
its contents. The browser differences may be accounted for by
different handling of this process by the browser where some create a
new document (so the existing - d - reference still refers to the old
document object (which then still shows the assigned method)) and
others (apparently like Opera) 're-set' the existing document
(removing any augmented properties in the process).
Jul 2 '08 #4
Problem solved:

var cousin2_doc = brother_frameset['main-bottom'].document
var d = {}
d.doc = cousin2_doc

d.wp = function( obj ) { this.doc.write( obj + '<p>' ) }
d.wp( d.wp )

var cn = cousin1_doc.childNodes
d.wp( cn )
Jul 2 '08 #5
Ma************@gmail.com wrote:
Problem solved:

var cousin2_doc = brother_frameset['main-bottom'].document
var d = {}
d.doc = cousin2_doc

d.wp = function( obj ) { this.doc.write( obj + '<p>' ) }
d.wp( d.wp )

var cn = cousin1_doc.childNodes
d.wp( cn )
cousin2_doc.write(cn);

somehow strikes me as being a lot less bloated.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jul 2 '08 #6
Henry wrote:
On Jul 1, 9:23 pm, Thomas 'PointedEars' Lahn wrote:
>MartinRineh...@gmail.com wrote:
>> d.wp = function( obj ) { this.write( obj + '<p>' ) }
alert( d + ', ' + d.wp )
d.wp( 23 )
alert( d + ', ' + d.wp )
At the first alert(), we're happy. The second alert shows
that the function is gone. I'm using KDE on Linux. Konqueror
doesn't have any problem with this.
The created Function object is _not_ gone (at least not
garbage-collected at once), but the test shows that you could
not augment the Document host object with a property, which
is not surprising. Host objects do not need to support
(arbitrary) augmentation, and it is up to their implementors
to define to what extent augmentation is possible.
<snip>

Wouldn't the symptoms of a failure to augment a host object be an
'undefined' appearing in the first alert, followed by an exception
being thrown at the - d.wp( 23 ) - line?
Not necessarily. I think I have seen this sort of "late garbage collection"
of user-defined properties of host objects before, but I don't remember
where and when anymore.
[...] I would suspect that the culprit is the line
- this.write( obj + '<p>' ) - inside the method, as that is
effectively a - document.write - call and that will (if the pertinent
document has finished loading) clear the existing document and replace
its contents. [...]
You are right, this is more probable and would explain why the OP's
(somewhat bloated) workaround works.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jul 2 '08 #7
Thanks gentlemen.

I've got it to where it works, which is good.

But I'm totally confused, which is not so good.

Given two frames, let's say A and B, js in A gets reference to B's
document and uses it to doc.write( something ). That would, I thought
erase prior content of B. How would that effect objects in js in A's
document? And now that I've thought about it, I see no reason why my
workaround should work. Any ideas?
Jul 3 '08 #8
Ma************@gmail.com wrote:
Given two frames, let's say A and B, js in A gets reference to B's
document and uses it to doc.write( something ). That would, I thought
erase prior content of B. How would that effect objects in js in A's
document?
When you add methods to an object existing in another frame B and overwrite
the contents of frame B afterwards, the least you can expect is that these
methods cease to exist.
And now that I've thought about it, I see no reason why my workaround
should work. Any ideas?
Your workaround adds a method to an object existing in frame A instead.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Jul 3 '08 #9
Your workaround adds a method to an object existing in frame A instead.
>

PointedEars
How obvious! Thanks.
Jul 3 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Martin Doyle | last post by:
Ok, I'm building a JS-based limitless-sublevel dynamic menu and am making it cross browser as well - 3 packs of aspirin so far and counting ;) I'm having a weird rendering problem using Opera...
5
by: news | last post by:
I've a site: http://gto.ie-studios.net/products.php that looks perfectly fine in Windows whether with IE or Firefox 1.0. But when viewed in the Linux version of Firefox 1.0, images get misaligned...
10
by: Andrew | last post by:
I'm developing a site using CSS layout. One of the main divs contains the content, another contains the side bar. I want the content next to the sidebar so the content is floated left and the...
14
by: nickdevx | last post by:
Without knowing "html before" and "html after" can anyone fathom any reason why the following code crashes IE but if I add <br/> after ANY <input> tags it doesn't? ...
2
by: Christian Kreimer | last post by:
Hi I created an C# windows forms application that holds a user control. The user control itself is an editor for geographical information systems and is based on an ActiveX Library for providing...
3
by: SpookyET | last post by:
I got private ChokeStatus clientChokeStatus;. In the constructor i got clientChokeStatus = ChokeStatus.Choked; and it is also used in a few other methods, but it keeps bitching The private field...
1
by: elizabeth13 | last post by:
Happy New Year, all. I'm hoping someone can help with a weird text formatting issue I'm seeing only in Safari. I change my template on a monthly basis (header, colors, etc), and this is the...
9
by: -Lost | last post by:
In Firefox and Safari for example, if I serve my XHTML documents as application/xml or xhtml+xml they only display the top inch or so of the document. In Opera it says "object has been blocked."...
12
by: -Lost | last post by:
In Firefox and Safari for example, if I serve my XHTML documents as application/xml or xhtml+xml they only display the top inch or so of the document. In Opera it says "object has been blocked."...
14
by: Summercool | last post by:
in http://www.0011.com/test_size3.html to center the logo "HTML 4.01 check" button at the bottom of the page, I used <div style="width: 10px; margin: 0px auto"> </div>
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.