473,762 Members | 8,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting image nodes in Safari

Hi all!

I dymically replace the child nodes of a DIV element by image nodes. In
IE and Firefox this works properly. In Safari it works properly, too -
but only if the site is called locally, eg. with file://. Uploading to a
server and viewing the site in Safari with http:// results in an error.

The problematic code is the following:

var node = document.create Element("img");
node.setAttribu te("src", filename);
node.setAttribu te("style", "position:absol ute;left:100px; "); // error
document.getEle mentById(name+" Images").append Child(node);

When executing this script on Safari in online mode (again: with a
_local_ file, it works fine!), Safari reports the following error,
occuring in the marked line:

"[592] :TypeError - No default value"

Obviously, node.style seems not available at this point. I think
Safari's still loading the image, and while loading it blocks all
accesses to node.

Is this assumption correct?

That would mean that in Safari, I cannot do _anything_ with the image
node until the image is loaded. These are not really bright prospects.

Regards,

-.Lutz.-

PS: I tried to enclose the image nodes in DIV elements and to apply
style properties to the DIVs. That lead to a DOMException 8 ("node does
not exist") when calling appendChild(nod e).
Jul 23 '05 #1
2 2076
Lutz Ißler wrote:
Hi all!

I dymically replace the child nodes of a DIV element by image nodes. In
IE and Firefox this works properly. In Safari it works properly, too -
but only if the site is called locally, eg. with file://. Uploading to a
server and viewing the site in Safari with http:// results in an error.

The problematic code is the following:

var node = document.create Element("img");
node.setAttribu te("src", filename);
node.setAttribu te("style", "position:absol ute;left:100px; "); // error
document.getEle mentById(name+" Images").append Child(node);

When executing this script on Safari in online mode (again: with a
_local_ file, it works fine!), Safari reports the following error,
occuring in the marked line:

"[592] :TypeError - No default value"

Obviously, node.style seems not available at this point. I think
Safari's still loading the image, and while loading it blocks all
accesses to node.

Is this assumption correct?
Sorry, I can't test this right now but... if your assumption is
correct, modifying the style before the src attribute should work.

That would mean that in Safari, I cannot do _anything_ with the image
node until the image is loaded. These are not really bright prospects.

Regards,

-.Lutz.-

PS: I tried to enclose the image nodes in DIV elements and to apply
style properties to the DIVs. That lead to a DOMException 8 ("node does
not exist") when calling appendChild(nod e).


var node = document.create Element('img');
node.alt = 'Picture of something';
node.style.posi tion = 'absolute';
node.style.left = '100px';
document.getEle mentById(name + 'Images').appen dChild(node);
node.src = filename;

Generated elements should comply with HTML 4 (or whatever DOCTYPE
you're using), so you need an 'alt' attribute too.

--
Rob
Jul 23 '05 #2
Hi RobG,

RobG schrieb:
Sorry, I can't test this right now but... if your assumption is
correct, modifying the style before the src attribute should work.
No it doesn't.
Generated elements should comply with HTML 4 (or whatever DOCTYPE
you're using), so you need an 'alt' attribute too.


Thanks for the tip.

In the meantime, I found the problem cause: the Content-Type header was
not matching the DOCTYPE declaration. IE and Firefox ignored that but
Safari didn't. Now, with matching text/html and HTML 4.01 DOCTYPE,
everything works as expected even with Safari online.

Thank you for the help,

-.Lutz.-
Jul 23 '05 #3

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

Similar topics

7
18924
by: Andrew Poulos | last post by:
I'm using the following code to create a small table with one column and two rows. An image goes into the first cell. //create table var t = document.createElement("TABLE"); t.style.position = "absolute"; t.style.left = "100px"; t.style.top = "100px"; t.style.width = "200px";
2
2118
by: Henri Sivonen | last post by:
I try to associate DOM nodes with other objects. Assigning custom properties to DOM nodes works in Firefox and Safari. It also works with HTML nodes in IE6. However, it appears not to work with XML nodes that are part of trees returned by XMLHttpRequest. How can I work around this limitation? For XML nodes, I need to be able to associate at most one object with each node. The syntax I am using is node.customproperty = value
5
1711
by: Bob | last post by:
Hi, I have a treeview which contains nodes of a class (classA) derived from treenode. These classA nodes may contain nodes of a class (ClassB) derived from classA. The form load populates a imagelist and calls a subroutine that assigns an image to each node depending on its type. If I expand a classA node, all is well. ie. I see the classA image on the classA node and the classB image on the exposed classB node (which is always
2
6481
by: Martin Honnen | last post by:
I was playing around with canvas support in recent Safari, Mozilla and Opera (only version 9 preview) but run into issues with Safari related to the very old DOM Level 0 Image object for preloading images. When doing e.g. var img = new Image(); img.onload = function (evt) { alert(this); }; img.src = 'whatever.gif';
7
3965
by: petermichaux | last post by:
Hi, I have tried the following based on suggestions of the best way to insert JavaScript into a page. This is instead of using eval(). Unfortunately IE says "unexpected call to property or method access" for the second to last line of my function. If you know what I've done wrong or how to fix it I would appreciate the help.
7
27502
by: fredo | last post by:
I've studied Eric Meyer's pure css popups, version two: http://meyerweb.com/eric/css/edge/popups/demo2.html which pops up an image when I roll over a text link. Now I want to pop up a large image when I roll over a thumbnail. I've tried some things, but can't make it work. See here (Warning: adult matter):
2
1625
by: cesarcesar | last post by:
Hi, XML novice here with another question. I need to add a XML node like, <child01> <child02> <text></text> <image>image 1</image> <image>image 2</image>
7
5224
by: David Stone | last post by:
Run into something recently that has left me a little puzzled. According to the examples in section 13.6.1 of html 4.01... <http://www.w3.org/TR/html401/struct/objects.html#h-13.6.1.1> I should be able to use <aelements with a specified shape and coords within a <mapso that I can use the links with an actual image and, at the same time, have the links appear as text. Something like the map associated with
2
1960
by: SMH | last post by:
I am in the process of converting all HTML documents, including many dynamic/interactive documents, to XHTML documents (because I want to incorporate SVG and MathML, among other things). I am having a problem converting document.write() statements which are not allowed in XHTML documents to statements which create the DOM nodes/elements dynamically within script elements.
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10137
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
9989
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...
0
9812
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
8814
agi2029
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...
1
7360
isladogs
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...
0
6640
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();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2788
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.