473,386 Members | 1,720 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,386 software developers and data experts.

Declaring a div using Javascript not working in Safari

I am a newbie. This is someone else's code which I have to modify to
work in Mozilla and Safari. The changes I made so far have allowed it
to work in Mozilla but not Safari. It seems to be getting hung up on
the first line of code. I put an alert after that line and I never saw
it in Safari but I did see it in Mozilla. Any Thoughts?

Thanks,
Andrew

Here's the code:
{
document.write("<div id='orbitLayer' style='position:absolute;
left:0px; top:"+document.all['topBanner'].offsetWidth+"px;
width:"+document.all['topBanner'].offsetWidth+"px;
height:"+(document.body.offsetHeight-document.all['topBanner'].offsetHeight)+"px;
z-index:2'>");
document.write("<object
classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ");
document.write("codebase='/flash/swflash.cab#version=4,0,2,0' ");
document.write("width='100%' ");
document.write("height='100%' ");
document.write("name='estee' ");
document.write("id='estee'>");
document.write("<param name=movie value='newmenu_pinkribbon.swf'>");
document.write("<param name=quality value=high>");
document.write("<param name='wmode' value='opaque'>");
document.write("<embed src='newmenu_pinkribbon.swf'");
document.write("quality=high
pluginspage='/flash/swflash.cab#version=4,0,2,0'");
document.write("type='application/x-shockwave-flash' ");
document.write("width='100%' ");
document.write("height='100%' ");
document.write("name='estee'");
document.write("id='estee'");
document.write("wmode='opaque' ");
document.write("swliveconnect='true'>");
document.write("</embed> ");
document.write("</object>");
document.write("</div>");
}

Feb 22 '06 #1
2 2492
dr*****@yahoo.com wrote:
I am a newbie. This is someone else's code which I have to modify to
work in Mozilla and Safari. The changes I made so far have allowed it
to work in Mozilla but not Safari. It seems to be getting hung up on
the first line of code. I put an alert after that line and I never saw
it in Safari but I did see it in Mozilla. Any Thoughts?


No specific thoughts, but I have heard a few times that Safari suffers
from a less-than-adequate Javascript implementation. Add to that the
fact that a LOT of people tend to write code that only works on their
chosen browser (IE, quite often) and don't worry about cross-browser
compatibility.

If I were in your position, I would check the Safari Javascript
documentation and verify the details of the implementation of
document.write - Also, have you tested it with a simpler string? (say,
document.write('hello');?)

Feb 22 '06 #2
dr*****@yahoo.com wrote:
I am a newbie. This is someone else's code which I have to modify to
work in Mozilla and Safari. The changes I made so far have allowed it
to work in Mozilla but not Safari. It seems to be getting hung up on
the first line of code. I put an alert after that line and I never saw
it in Safari but I did see it in Mozilla. Any Thoughts?

Thanks,
Andrew

Here's the code:
{
document.write("<div id='orbitLayer' style='position:absolute;
left:0px; top:"+document.all['topBanner'].offsetWidth+"px;
width:"+document.all['topBanner'].offsetWidth+"px;
height:"+(document.body.offsetHeight-document.all['topBanner'].offsetHeight)+"px;


Safari does not support document.all. Mozilla (and other Gecko-based
browsers) provide 'undetectable' support for it in quirks mode. There
are suggestions on how to work with that in the FAQ:

<URL:http://www.jibbering.com/faq/#FAQ4_15>
You could do something like:

function getEl(id)
{
// Use getElementById if available - suits perhaps 90% of browsers
if (document.getElementById) return document.getElementById(id);

// Otherwise, use document.all if available - suits IE 4
if (document.all) return document.all[id];

// Otherwise return null - maybe 0.5% of browsers will end up here
return null;
}
Then in your code can be:

var tBanner = getEl('topBanner');
if (tBanner){
document.write( "..." + tBanner.offsetWidth + "...");
...
}
Multiple calls to document.write are inefficient, better to concatenate
the HTML as string, then use a single document.write, e.g.:
var tBanner = getEl('topBanner');
if (tBanner){
var htmlString = "<div id='orbitLayer' style='position:absolute;"
+ " left:0px; top:"
+ tBanner.offsetWidth
+ " px;z-index:2'><object"
+ " classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'"

// ...

+ "swliveconnect='true'>"
+ "<\/embed> "
+ "<\/object>"
+ "<\/div>";

document.write( htmlString );
}

[...]
--
Rob
Feb 22 '06 #3

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

Similar topics

5
by: Foreman | last post by:
Using ASPFileUpload (http://support.microsoft.com/default.aspx?scid=kb;en-us;299692) and works for IE6 and FireFox but not Safari. Thanks in advance for your assistance.
6
by: abdullah1983 | last post by:
Hi Guys, I need some clarification regarding the problem with safari browser. Please find my code below. I'm setting the image src, mouseover and mouseout using javascript. The mouseover and...
133
by: Alan Silver | last post by:
Hello, Just wondered what range of browsers, versions and OSs people are using to test pages. Also, since I don't have access to a Mac, will I have problems not being able to test on any Mac...
3
by: Joe Cox | last post by:
I am having a problem with style properties for dynamic images in Mac OS X Safari. By dymanic images, I mean images allocated with the javascript 'new Image()' call. With static images (created...
2
by: vendredi5h | last post by:
Hello, Yesterday I spent a lot of time to find why my javascript script was not working on Safari. I finaly found a solution but not the reason. And I'd like to know if someone could tell me if...
2
by: darren | last post by:
I have a small Javascript problem with that mutch love web browser safari, I tested the code on all other browsers PC (Win) and Linux and IE on the mac and it seams to work ok, but for some reason...
3
by: noballack | last post by:
I've got a problem, I'm working with Ajax in a web with a form with a list of checkbox added to the form via an Ajax.Updater method. These added checkboxs are not been sended by the form if I use...
13
by: Zwerfkat | last post by:
When running the code below, all browsers are showing "Hello World" except Safari which cannot match the regular expression. See also http://www.testabc.nl/safari/test.html When I change *? into...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.