473,671 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DOM and Opera

Hello

I am trying to use DOM to create an object in a document and wish to be
compativle with Opera

My code is

containerDiv = document.create Element("div"); //create download
container div
containerDiv.se tAttribute("id" , "statusContaine r");
containerDiv.st yle.position = "absolute";
//containerDiv.st yle.left = x + "px";
//containerDiv.st yle.top = y + "px";
containerDiv.st yle.left = 100 + "px";
containerDiv.st yle.top = 100 + "px";
containerDiv.st yle.width = "293px";
containerDiv.st yle.height = "80px";
//containerDiv.st yle.visibility = "hidden";
containerDiv.st yle.borderStyle = "groove";
containerDiv.st yle.borderColor = "#b7b7b7";
containerDiv.st yle.borderWidth = "2px";

(put stuff in div).... and finally......

document.body.a ppendChild(cont ainerDiv);

This works in IE 6+ and gecko, but does not work in Opera ( I currently
have verson 7.11)

I've tried to filter on if (document.creat eElement) but Opera passes the
test.

I've read the Opera support documentation it it seems that this should
work. Can anyone let me know if I am barking up the wrong tree?

Many Thanks

Michael

Jul 20 '05 #1
3 1664


Michael Phillips wrote:
I am trying to use DOM to create an object in a document and wish to be
compativle with Opera

My code is

containerDiv = document.create Element("div"); //create download
container div
containerDiv.se tAttribute("id" , "statusContaine r");
containerDiv.st yle.position = "absolute";
//containerDiv.st yle.left = x + "px";
//containerDiv.st yle.top = y + "px";
containerDiv.st yle.left = 100 + "px";
containerDiv.st yle.top = 100 + "px";
containerDiv.st yle.width = "293px";
containerDiv.st yle.height = "80px";
//containerDiv.st yle.visibility = "hidden";
containerDiv.st yle.borderStyle = "groove";
containerDiv.st yle.borderColor = "#b7b7b7";
containerDiv.st yle.borderWidth = "2px";

(put stuff in div).... and finally......

document.body.a ppendChild(cont ainerDiv);

This works in IE 6+ and gecko, but does not work in Opera ( I currently
have verson 7.11)


Try to be more specific, does not work can mean a lot of things. Have
you looked at the JavaScript console, does it show any errors?
Does the div show up in the document? Is content missing?

I have tried your code with Opera 7.20, extended it to put a text node
with some text into the div and after removing the broken comment the
code works without showing errors in the JavaScript console and the div
shows up in the document.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Michael Phillips <mi********@yah oo.com> writes:
I am trying to use DOM to create an object in a document and wish to be
compativle with Opera
Just follow the W3C DOM and it should work.
containerDiv = document.create Element("div"); //create download
container div
Beware of newsclients wrapping lines. Yours does, so you should always
make sure the code you post is no longer than ~72 characters per line.
containerDiv.se tAttribute("id" , "statusContaine r");
I would just write
containerDiv.id = "statusContaine r";
(put stuff in div).... and finally......
I did that, using:
containerDiv.ap pendChild(docum ent.createTextN ode("XXX"));
and
document.body.a ppendChild(cont ainerDiv);
and it worked in Opera 7.5 (preview) and 7.23 (most recent official release).
I guess the problem is in the (put stuff in div) part.
This works in IE 6+ and gecko, but does not work in Opera ( I currently
have verson 7.11)
I don't have O7.11 installed any more, but I don't see anything in the
code above that I haven't used since 7.0 beta.
I've tried to filter on if (document.creat eElement) but Opera passes the
test.
Yes, it exists and is functional.
I've read the Opera support documentation it it seems that this should
work.
It should.
Can anyone let me know if I am barking up the wrong tree?


Try posting the remainder of the code (or give a link, so you won't
have to worry about lines being wrapped).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
To All

I appreciate the responses. I have loaded 7.2 and get the same results. I
am stumped. I know I must be missing something really obvious, but just
cannot see it.

I posted my source code below. I commented out all the internal stuff. In
Mozilla and IE I do see the div wth boarder. In Opera I see nothing. I
tried eveything I could think of to isolate the error but get no where.

The message in the Opera javascript console is:

Event thread: onload
Error:
name: TypeError
message: Statement on line 74: Expression evaluated to null or undefined and
is not convertible to Object: document.body
Backtrace:
Line 74 of inline#1 script in file://localhost/C:/HTML Projects/Projects
In Development/Walter G Meyer/Sandbox/dltest.htm
document.body.a ppendChild(cont ainerDiv);
At unknown location
{event handler trampoline}

Source code follows:

<head>
<head>
<title>Downlo ad Test Page </title>

<script type="text/javascript" language="javas cript">
function pageInit()
{
containerDiv = document.create Element("div"); //create download container
div
containerDiv.se tAttribute("id" , "statusContaine r");
containerDiv.st yle.position = "absolute";
//containerDiv.st yle.left = x + "px";
//containerDiv.st yle.top = y + "px";
containerDiv.st yle.left = 100 + "px";
containerDiv.st yle.top = 100 + "px";
containerDiv.st yle.width = "293px";
containerDiv.st yle.height = "80px";
//containerDiv.st yle.visibility = "hidden";
containerDiv.st yle.borderStyle = "groove";
containerDiv.st yle.borderColor = "#b7b7b7";
containerDiv.st yle.borderWidth = "2px";

//textImage = document.create Element("img"); //create download text
message image
//textImage.setAt tribute("id", "msgText");
//textImage.src = "./scripts/dlPageMsg.png";

//dotImageOne = document.create Element("img"); //create download text dot
images (3)
//dotImageOne.set Attribute("id", "msgDot_1") ;
//dotImageOne.src = "./scripts/dlPageDot.png";
//dotImageOne.sty le.position = "relative";
//dotImageOne.sty le.top = "4px";
//dotImageOne.sty le.visibility = "hidden";

//dotImageTwo = document.create Element("img");
//dotImageTwo.set Attribute("id", "msgDot_2") ;
//dotImageTwo.src = "./scripts/dlPageDot.png";
//dotImageTwo.sty le.position = "relative";
//dotImageTwo.sty le.top = "4px";
//dotImageTwo.sty le.visibility = "hidden";

//dotImageThree = document.create Element("img");
//dotImageThree.s etAttribute("id ", "msgDot_3") ;
//dotImageThree.s rc = "./scripts/dlPageDot.png";
//dotImageThree.s tyle.position = "relative";
//dotImageThree.s tyle.top = "4px";
//dotImageThree.s tyle.visibility = "hidden";

//statusLine = document.create Element("span") ; //create status text span
//statusLine.setA ttribute("id", "statusMsg" );
//statusLine.styl e.position = "absolute";
//statusLine.styl e.left = "70px";
//statusLine.styl e.top = "50px";
//statusLine.styl e.fontFamily = "arial";
//statusLine.styl e.fontSize = "13px";
//statusLine.styl e.fontWeight = "bold";
//statusLine.inne rHTML = "( ... Image " + currentImage + " of " +
itemArray.lengt h + " ... )";

//containerDiv.ap pendChild(textI mage); //construct download status
graphic
//containerDiv.ap pendChild(dotIm ageOne);
//containerDiv.ap pendChild(dotIm ageTwo);
//containerDiv.ap pendChild(dotIm ageThree);
//containerDiv.ap pendChild(statu sLine);

document.body.a ppendChild(cont ainerDiv); //append download status
graphic to document note: this is line 74
alert("boo");

//flagDL = 1;

}

onload=pageInit ;
</script>

</head>

<body">

</html>
</body>



Jul 20 '05 #4

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

Similar topics

4
2335
by: Spijon | last post by:
Seems opera can not work normally with javascript, does anyone knows how to fix it? Thanks in advance.
6
2073
by: Anthony Williams | last post by:
Hi, I have a web page that works fine in Opera 7 and other modern browsers (IE6, Mozilla 1.4, NS7.1, etc.), but not in Opera 5. I know which style properties to set for Opera 5 to make it work, but these affect the layout in the other browsers in a way that I don't find acceptable. Is there a way of writing properties that apply only to Opera 5, or of writing properties that will be hidden from Opera 5, so I can set the Opera 5 values,...
7
1810
by: TheMartian | last post by:
Opera is driving me nuts, I am trying to get it to actually render a table the full width of the browser window sounds easy, but no, Opera and only Opera leaves a 16px margin on the right edge I know its a bug in Opera, but does anyone know of anyway round it? All other current browsers I tested render correctly, and yes that even includes that nasty IE thing
13
2526
by: TheKeith | last post by:
Is it just me or does opera and ie not render the float style properly? IE does a sucky job at it, but opera makes a total mess; Mozilla/Firefox renders it correctly however. I'm just trying to be a good boy following the html 4.01 strict spec, and taking it a step further by not using tables for layout, but it's becoming a real pain. You would figure putting a strict doctype declaration at the top of the page would create a uniformity in...
4
2151
by: The Master | last post by:
Why will the unordered list not float in opera 7.5 unless a fixed/liquid width is applied to the unordered lists containing block? Then on the same token why does specifying a fixed/liquid width on the containing block then cause the floating to brake in safari 1.2 (it also brakes it in opera 4-6, hence the reason I use a sudo-element not recognized by opera 4-6 so it doesn't apply the fixed/liquid width)? ...
0
18451
by: BGS | last post by:
I have a web site (www.on-the-matrix.com) that displays photos in a "slide show" format on ASPX pages that run in an inline frame on an ASP page (or in a separate pop-up window). The ASPX pages use a hidden form to transmit information back to the server so it will know which is the next photo to load. All of this works as intended in modern versions of Internet Explorer, Netscape and Mozilla. With Opera, however, users receive a...
6
2711
by: Jeremy | last post by:
I really want to make my scripts work in Opera. I really, really do. But it seems like an uphill struggle. First of all, I can't get ANY kind of debug output. No error messages in the "javascript console" - but then, I have never seen ANYTHING in Opera's javascript console. Is there some kind of voodoo I need to perform in order to make that work? Then, when Opera doesn't like something about a script (even if it works fine in...
41
3218
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to resolve this issue once and for all now. The problem might be PHP related but since I only develop applications using PHP, I'm not a hundred percent sure. Therefor I've taken the liberty to crosspost to comp.lang.php and alt.www.webmaster. I...
0
8476
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
8393
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
8820
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
8670
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
7433
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
6223
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
4224
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...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2810
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

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.