Javascript failure with I.E. ? [J.S. Expert]

  • Thread starter Mise en place du service Groupes
  • Start date
M

Mise en place du service Groupes

Hi,

Ever had pb with Javascript that works in Fx and not in I.E. ?

I try to have a javascript that position an element in the top of an
HTML Page.
The object is to load the javascipt that will position an HTML content
in the top of the page.

Having a javascript that does this works in I.E. and Firefox.

The problem is to insert a javascipt within this javascipt that works
using I.E.


I use this javascript (my_script.js) :


document.write("<style type=\"text/css\">.style_eco01{top: 0; left: 0;
right: 0; position: absolute; text-align:center;background-
color:#E7E7E7;
width:100%; z-index:9999;} html>body .bandeau_pub {position:
fixed;}</style>");

if (document.all)

{
document.write("<style type=\"text/css\">.style_eco01{left: expression(
( 0
+ ( ignoreMe1 = document.documentElement.scrollLeft ?
document.documentElement.scrollLeft : document.body.scrollLeft ) ) +
'px' );
right: expression( ( 0 + ( ignoreMe2 =
document.documentElement.scrollRight
? document.documentElement.scrollRight : document.body.scrollRight ) )
+
'px' ); top: expression( ( 0 + ( ignoreMe =
document.documentElement.scrollTop ?
document.documentElement.scrollTop :
document.body.scrollTop ) ) + 'px' ); background-color:#E7E7E7;
z-index:9999; position: absolute; width:100%;}</style>");
}

document.write('<div id="pub" class="style_eco01">');
document.write('<scr' + 'ipt LANGUAGE="JavaScript">');
document.write('my_ygm = "top";');
document.write('my_ygm = 336;');
document.write('my_ygm_channel = 01ECO;');
.....
document.write('</scr' + 'ipt>');
document.write('<scr' + 'ipt LANGUAGE="JavaScript"
src="http://my_ygm.com/....js"></scr' + 'ipt>');
document.write('</div>');


This file is called from any html page.
The script works from any html page. Using the firefox browser :
everything is fine.

The problem is with I.E., where the script is positionned in the page
where it is inserted and not on the top of the web page.

The aim is to show the elements in a div on the top of the window.

How do you think this could be done in I.E. ?

We thank you very much for your advise.

Team & Aude
 
R

Rob ^_^

Hi,

First up enclose your document write arguments in single quotes,

document.write("<style type=\"text/css\">.style_eco01{top: 0; left: 0;
right: 0; position: absolute; text-align:center;background-
color:#E7E7E7;
width:100%; z-index:9999;} html>body .bandeau_pub {position:
fixed;}</style>");
Should be
document.write('<style type=\"text/css\">.style_eco01{top: 0; left: 0;
right: 0; position: absolute; text-align:center;background-
color:#E7E7E7;
width:100%; z-index:9999;} html>body .bandeau_pub {position:
fixed;}</style>');

Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top