Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opera problem

Status
Not open for further replies.

VJar

Programmer
Aug 3, 2002
18
UA
Why my cod workes in Internet Explorer 6 and changes width of the layer
from 200 px to 1000 px, but in Opera 6 not?
Help to correct this problem, please.

My cod:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;&Ntilde;&icirc;&auml;&aring;&eth;&aelig;&egrave;&igrave;&icirc;&aring;-&Ograve;&egrave;&iuml;&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>
<div id=&quot;layer1&quot; style=&quot;position:absolute; width:200px; height:115px; left: 125px; top: 24px; background-color: #FF0000;&quot;>

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
layer1.style.width=1000;
</script>

</div>
</body>
</html>
 
The reason is that you try to do it non-standard way.
This is the right way:

function changeDims(layerName, w, h) {

document.getElementById(layerName).style.width = w;
document.getElementById(layerName).style.height = h;
}

<a href=&quot;#&quot; onclick=&quot;changeDims('first', 300, 100)&quot;>change elem1 size</a>

This works on Opera 6, IE5 and Mozilla.
 
Ok. This script workes in Opera, but I need that script workes
automatic, for example so he workes in Internet Explorer:


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;&Ntilde;&icirc;&auml;&aring;&eth;&aelig;&egrave;&igrave;&icirc;&aring;-&Ograve;&egrave;&iuml;&quot; content=&quot;text/html; charset=iso-8859-1&quot;>

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
function changeDims(layerName, w, h) {

document.getElementById(layerName).style.width = w;
document.getElementById(layerName).style.height = h;
}
</script>
</head>

<body>
<div id=&quot;first&quot; style=&quot;position:absolute; width:200px; height:115px; left: 125px; top: 24px; background-color: #FF0000;&quot;>

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
if (screen.width==1024)
changeDims('first', 500, 100)
</script>

</div>
</body>
</html>
 

<head>
<script>
function changeDims(layerName, w, h) {
document.getElementById(layerName).style.width = w;
document.getElementById(layerName).style.height = h;
}

function checkAndSet() {
if (screen.width==1024)
changeDims('first', 500, 100)

else if (screen.width < 1024)
changeDims('first', 300, 80)
}
</script>
</head>

<body onload=&quot;checkAndSet()&quot;>

 
Method &quot;Onload&quot; begins to work when all oblects loaded. I need to set the style.width and height before any object begins loading
 
How can you set anything of an object before it is loaded??

Do you mean you don't want the object visible for the user until after it has been resized?

Then please check and/or respond to your other thread:

thread216-336138
 
Then I can suggest this:
write CSS styles dynamically according screen dims condition. Something like this:

<head>
<script>
if (screen.width==1024)
{w = 500;
h = 100;
}
else
{w = 300;
h = 80;
}
document.write(&quot;<style>.first { width:&quot;, w, &quot;;height:&quot;, h, &quot; }</style>&quot;);
</script>
</head>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top