Alright, so generally I'm using document.create Element("IMG"). ... but, I've noticed something just recently that made me switch to "new Image()"
What I'm doing is creating a photo gallery of sorts, where i basically want to supply a total # of images, rows/cols max thumb/full image and let the script do the work. The solution I've opted for is to load the images once and change their size / position / visibility to show "thumb galleries" or "full image size" [and allow for pagination and all the bells & whistles]....
Naturally, the problem relates to the size of the images. When I first load a gallery, I load all the images off screen without height/width specified... I then use the onLoad event of the images to grab the "correct" height/width. -
function Photo( ... ) {
-
...
-
this.element = document.createElement("IMG");
-
this.element.onload = callbackFunc( this, "init" );
-
...
-
}
-
-
/* callbackFunc is a function I use to let me use "this" inside an event handler
-
-- similar to prototype's "bindAsEventListener" for those familiar with it */
-
-
/* _event = Event object; _this = source element (loaded image) */
-
Photo.prototype.init = function( _event, _this ) {
-
this.width=_this.width;
-
this.height=_this.height;
-
}
-
I noticed the height/width of my image were being populated as 0. Only in Internet Explorer -- and intermittently. I think that may have something to do with cached images ... or something. So, I was racking my brain for literally HOURS over this stupid little thing.... and finally, I ended up switching to: - this.element = new Image()
and now it works in both browsers.... all the time.
anyone else noticed this problem? I saw a post about it on some other forum, but there was no resolution to the problem.
4 23930
Noooooo IE fails me miserably again.
So, when one is trying to do DOM manipulation between new windows, any elements created must be created in that context.... otherwise IE will raise the most obscure error I have ever seen: "No Such Interface Supported". -
// open up a new window...
-
var a = window.open("about:blank", "a");
-
-
// create an element using this document
-
var test = document.createElement("DIV");
-
test.appendChild( document.createTextNode("This is a test") );
-
-
// this works in Firefox; IE returns "no interface supported"
-
a.document.body.appendChild( test );
-
-
// the workaround is to change the creation slightly:
-
var test2 = a.document.createElement("DV");
-
test2.appendChild( document.createTextNode("test #2") );
-
-
// this works in both browsers
-
a.document.body.appendChild( test2 );
-
So that's fine, the way my code is written I can easily enough change my toDOM function to take a parameter of which document to use to create -- and I can easily enough set that to be the document of the new window.... the problem? -
this.element = new Image()
-
Noooooooooooooo ooooo..... When I switch it to "createElem ent" it won't load the images, when I change it to "new Image()" it gives me an "Interface not supported error"......... .... Is there a way to jiggle the "new Image()" to be created in the context of another document? Anyone?
AW hell yea! I got it!
The order of execution I was using:
1) "load Gallery": init the form, loading each image -- which leads to:
2) "image preLoad": create image element & set all properties, including src -- this also sets the "onload" function handler to eventually handle the height/width & finally appends the image to form
4) image loads and the onload handler fires, but with "createElement( 'IMG')" IE was returning 0/0 for height/width
Basically what I did was move the "appendChil d" line from the preLoad code (before it was actually loaded) to the onload handler (after it had finished loading), and that seemed to do the trick. I guess when you append a dynamically-created, non-loaded image to the form, when the image finally does load, while inside the onLoad event handler, the height/width of target will return 0/0... in IE. EVEN THOUGH, and this is the messed up part that had my mind thinking of awful hacks, the height/width are visible in the outerHTML property: -
alert( _this.outerHTML )
-
/* returned
-
<IMG
-
class=Link
-
id=Photo0
-
style="LEFT: 0px; POSITION: absolute; TOP: 0px"
-
height=720 src="photos/0.jpg"
-
width=960 border=0>
-
*/
-
alert( _this.width );
-
// returned 0
-
I've said it before and I'll say it again: IE can suck my nuts.
Ah ha ha ha.... I spoke too soon.
IE displays the images fine, which was the original problem... the first "onclick" that I call (clicking an image to show full size) works, but raising any event handlers after that will .. get this .. completely hang the IE window..... no errors, no "infinite loop cancel script" prompt... nothing. Just [Not Responding].
I'll post more when I figure it out... my hunch is it has something to do with re-attaching the events after it loads -- but the strange thing is, the first event loads fine..... I'm using the callbackFunc for each.
IE memory leak problems, anyone?
[edit] Oh yea... need I mention that Firefox works fine?
acoder 16,027
Recognized Expert Moderator MVP
IE displays the images fine, which was the original problem... the first "onclick" that I call (clicking an image to show full size) works, but raising any event handlers after that will .. get this .. completely hang the IE window..... no errors, no "infinite loop cancel script" prompt... nothing. Just [Not Responding].
I'll post more when I figure it out... my hunch is it has something to do with re-attaching the events after it loads -- but the strange thing is, the first event loads fine..... I'm using the callbackFunc for each.
IE memory leak problems, anyone?
Possibly. Can you post an example.
Interesting problem. Thanks for posting your 'discoveries' :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Gregory |
last post by:
Hello,
I'm trying to do the above in order to process an image and return the
result to an html image control. It fails and my key suspects are either
the variable that I'm passing in - ImageName - for processing, or the return
data which is done (or not as the case may be) by imagejpeg($img) in the
script, after header("Content-type: image/jpeg").
Any insights would be most welcome, especially debugging techniques and a
pointer to...
|
by: Mike Kamermans |
last post by:
I'm trying to determine where inside an XHTML's DOM a javascript function
is triggered, but when I use the construction of calling a function with
"this" as parameter and then checking the event target inside the
javascript function, I get very very little love from javascript in an
XHTML setting.... I have put up the file that demonstrates my problem at:
http://www.nihongoresources.com/downloads/test/test.xml
(the jscript bit is...
|
by: Allen |
last post by:
I am trying to add an additional photo/hyperlink to the company web
site (I didn't create it) without any luck. The mouseover feature
'highlights' pics by swapping them with another pic using this command
in some type of array. I added the mailbox in the lower left corner
(see link below)http://www.aamechanical.com/indextemp.htm
but I cannot get it to swap. Here is the code for the page:
Thanks for your help in advance
|
by: Sander Tekelenburg |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The HTML specs speak of "replaced" and "non-replaced" elements, yet
for the life of me I can't find an explanation of what "replaced" is
supposed to mean in this context. Can someone explain?
TIA
|
by: Burak Gunay |
last post by:
Hello,
In my asp.net 2.0 page, I have a hyperlink with an arrow image
<a id="imgtest" href="#"onclick="return hideColumn()">
<img id="imgArrow" src="App_Themes/Trmis/WebResource3.gif"
alt="Click" />
</a>
WebResource3.gif is an arrow pointing left and when I click on it I
| |
by: mikek12004 |
last post by:
1) Script Title: Rich HTML Balloon Tooltip
2) Script URL :http://www.dynamicdrive.com/dynamicindex5/balloontooltip.htm
3) Problem Description:
See this page
General Music
for links you can see without scrolling down the div the tooltip is shown at the desired place but when you scroll donw the div the tooltip's position gets all messed up, e.g in the last "ΤΙΤΛΟΣ ALBUM" (which means Title of album ) the tooltip gets in front of the...
|
by: enaz |
last post by:
Ok, so, this is my first post, if there is any info i am leaving out please tell me
this is the function:
function mouseOver(c)
{
alert(c); <!-- just for debugging-->
if (c.src == "red.jpg")
{
|
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,...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |