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
 
N

naixn

Mise en place du service Groupes wrote :
Hi,

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

Quite always at the beginning. Firefox is using Javascript 1.7, and IE uses
javascript 1.2... so there are a lot of differences...
--
A vrai dire tout le temps, surtout aux débuts, puisque Firefox utilise
la version 1.7 de javascript, alors que IE utilise javascript 1.2
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.

Why don't you do it with CSS ? There's a way in CSS to tell the div not to be
relative, but rather to have a fixed position, like:
position: fixed;
top: 10px;
left: 100px;
--
Vous devriez essayer avec un fichier CSS plutôt qu'avec javascript. Il y a une
façon plutôt simple de dire à une élement, comme un <div> par exemple, de ne
pas avoir une position relative aux autres élemens, mais une position bien
particulière comme :
position: fixed;
top: 10px; // On positionne à 10 pixels du haut de la fenêtre
left: 100px; // on positionne à 100 pixels à partir de la gauche.
 
V

VK

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

Yep... And vice versa ;-)
I try to have a javascript that position an element in the top of an
HTML Page.

Is it some "Loading..." temporary content? Why not using CSS directly?
The object is to load the javascipt that will position an HTML content
in the top of the page.

Not sure I understood that. Could you explain more?
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>");

position: fixed was not invented yet :) (unless for
background-attachment property). For elements it is
static (default)
relative
absolute
 
V

Vince Morgan

Mise en place du service Groupes said:
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)

You could try
<snip>
if(document.all) {
var script=document.createElement("script");
script.type="text/javascript";
script.src="JavaScript/yourScript.js";
document.getElementsByTagName("head")[0].appendChild(script);
}
</snip>

The code should parse as though it were part of the already embedded script.

{
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

HTH
Vince Morgan
 
B

bertrand.foing

Hy,
In fact my problem is that I need to put an element in the top of an
Html page using a javascript file.
the script <script langage="javascript" type="javascript"
src="myFile.js"></script> can be pasted everywhere in an html page, so
it's easier for biginners.

Using
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 .style_eco01 {position: fixed;}</style>");
document.write("<div class=\"style_eco01\">....</div>");
it works very well on IE and Firefox, i can insert everything in my
div...

But I tried t insert script from another .js file inside my div, using
document.write('<div id="id" 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>');

That works well on Firefox, but on IE, it doesn't go on the top in my
div, it simply goes where
<script langage="javascript" type="javascript"
src="myFile.js"></script> is pasted...

I tried to use css file, without success...

Do you have an Idea how to solve this problem ?

Thank you very much

Bertrand
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top