var browserName=navigator.appName;
var element=getElementById("socialContainer");
if (browserName=="Microsoft Internet Explorer")
{
function style(onload)
{
element.style.padding-right="100px";
}
}
I am making a script so that only in Internet Explorer it moves the socialContainer id over from the right 100px
this all looks right to me but I dont know javascript all too well so idk. Wondering if you guys could help me.
Code Help
Started by Howdy_McGee, Jun 10 2010 10:30 AM
5 replies to this topic
#1
Posted 10 June 2010 - 10:30 AM
|
|
|
#2
Posted 10 June 2010 - 05:42 PM
hmm why don't you check the browser version with PHP? That's how I always do it:
You can find a complete list here:http://www.pgts.com....rowser_list.txt.
This way you can very easily check the browser and do different actions for different browsers.
Cheers,
Bjorn
<?php echo($_SERVER[‘HTTP_USER_AGENT’]); ?>This gives you the Browser Version. Here is a list of possible outputs:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC) Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
You can find a complete list here:http://www.pgts.com....rowser_list.txt.
This way you can very easily check the browser and do different actions for different browsers.
Cheers,
Bjorn
#3
Posted 10 June 2010 - 08:47 PM
Well, a more ideal way you would do it like Bjorn suggested, would be using PHP's stripos function.
if (stripos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
print "function style(onload)
{
element.style.padding-right='100px';
}"; //Internet Explorer-specific code
}
#4
Posted 10 June 2010 - 09:16 PM
That's exactly what I meant Nullw0rm :)
I just wanted to give McGee a push in the right direction. ^^
Cheers,
Bjorn
I just wanted to give McGee a push in the right direction. ^^
Cheers,
Bjorn
#5
Posted 11 June 2010 - 09:16 AM
Here is what you are looking for i believe. Also if you want to use padding you need to do it to the left of the object to shift it to the right.
Oh and I was trying to figure this out for a while until I realized that it needs to have a relative position; it has to be relative to move.
<html>
<head>
<script type="text/javascript">
function mover()
{
var browserName=navigator.appName;
if (browserName=="Microsoft Internet Explorer")
{
document.getElementById('cont').style.position="relative";
document.getElementById('cont').style.left="100";
}
}
</script>
</head>
<body onload="mover()">
<div id="cont">Hello there</div>
</body>
</html>
Oh and I was trying to figure this out for a while until I realized that it needs to have a relative position; it has to be relative to move.
#6
Posted 13 June 2010 - 02:01 PM
:/ see I don't understand PHP... I understand a fair amount of javascript so that's why i'd rather go that route.


Sign In
Create Account


Back to top









