473,657 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

prototype.js issue: IE thinks $() ain't the same as document.getEle mentById()

[X-posted to the ruby-on-rails-spinoffs mailing list...]

JavaScripters:

Steps to reproduce the bug:

Save this in "outer.html ":

<div id='updateMe'></div>
<iframe src='inner.html '/>

Now save this into "inner.html ":

<input type='button' value='control'
onclick="window .parent.locatio n.href =
&quot;javascrip t:void(document .getElementById ('updateMe').in nerHTML
= 'control')&quot ;"/>

<script src="/javascripts/prototype.js?11 68956448"
type="text/javascript"></script>

<input type='button' value='experime nt'
onclick="window .parent.locatio n.href =
&quot;javascrip t:void($('updat eMe').innerHTML =
'experiment')&q uot;"/>

Surf Internet Explorer (7 BTW) to outer.html, and observe two buttons.

Click 'control', and observe that the outer.html's div updates to 'control'.

Observed behavior:

Click 'experiment', and observe a null-object crash. $() could not find the
same value as getElementById( ).

Expected behavior:

Because the javascript:void trick evaluates in the context of the target
frame (not the source frame), the behaviors of $() and getElementById( )
should be exactly the same inside the javascript:void () line as inside the
target frame, right?

(BTW I suspect from related evidence that the code "works" in Firefox...)

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!
Jan 19 '07 #1
2 2223
Phlip wrote:
[X-posted to the ruby-on-rails-spinoffs mailing list...]
Mention of prototype.js in these parts is a great way of bringing down a
ton of bricks!

--
Ian Collins.
Jan 19 '07 #2

Phlip wrote:
[X-posted to the ruby-on-rails-spinoffs mailing list...]
Not cross-posted, multi-posted. Your answer is in the rails spin-offs
group.

In short, it is bleedin' obvious that Prototype's $() is not the same
as getElementById( ), nor is simply a short substitute (though it can
be, and often is, used as such).

Your "bug" is not a bug but a misconception on your behalf.
--
Rob

Jan 19 '07 #3

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

Similar topics

7
2196
by: Brian Genisio | last post by:
Hi all, Does anyone know of a way in IE to determine the prototype name of an object? For instance, in Mozilla, I can say: junk = document.getElementById("myID"); alert(junk.toString());
8
3746
by: Elf M. Sternberg | last post by:
One of the complaints about prototype.js (google for it if you're not familiar with it) is that it's poorly documented. I have this inkling that the key to understanding prototype.js is in the bind function. The problem with Javascript is that the "this" operator is poorly overloaded and it is often hard to understand in the context of object-oriented javascript So, let's start with the definition:
12
2191
by: petermichaux | last post by:
Hi, I've been reading the recent posts and older archives of comp.lang.javascript and am surprised by the sentiments expressed about the prototype.js library for a few reasons: 1) The library has been referred to as "junk" many times which is a strong opinion against the relatively high popularity of the library. I know popularity doesn't make something good.
1
1292
by: drnicwilliams | last post by:
The Prototype library gives us the $() operation for converting a DOM element id into the DOM element: $('element-id'). It also appends a bunch of functions to the resulting object. Sometimes though, passing a string into the $() function doesn't read well; and only makes Javascript code harder to read. For example: $(window.button_list()).hide() Instead, it'd be nice to have normal chainability. I like the following syntax:...
6
2530
by: Nico VanHaaster | last post by:
Hello all, I have run across an issue with IE 6.0+. I have a page that makes an XMLHttpRequest to the webserver to update a report on the page. The first time you hit the refresh report button the data is refreshed, however if you try to refresh the report the onreadystatechage does not seem to fire. I have tested this by placing an alert in the verifyID2 & verifyID3 function to track where the XMLHttpRequest currently is. Now when...
3
2582
omerbutt
by: omerbutt | last post by:
hi there i have downloaded a prototype tooltip from http://www.nickstakenburg.com/projects/prototip/ the logic it uses is to call the script after creating the <div> for example i am using the ajax method <html> <body> <div id='my_div'> </div>
1
1549
Stang02GT
by: Stang02GT | last post by:
Here is the issue that I am having. I have two text feilds where users need to enter a "From Date:" and a "To Date:" they then hit a update button and my code will pull back the data for the date ranges they have selected. If the user enters the same date in both from and to fields they are expecting to see just one row returned for that day, BUT what is really happening is it is returning all the data. Does anyone have any suggestions or...
1
5794
by: chaitanyadotcom | last post by:
As per my application i need to create tabs using iFrame dynamically. There are totally 4 buttons in my application where for each button i provide a link. Where in it will dynamically create a tab inside the iFrame. For example.. first button contains google.com second button contains yahoo.com 3rd button contains hotmail.com if i click on first button i.e google.com , tab is created and link to google.com is generated as a tab in...
0
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.