View Full Version : Can someone write me a script?
Benjamindaines
Aug 22, 2006, 06:49 PM
Can someone write me a script to embed into my website that would detect what browser a visitor is using, if it's Safari, Camino, or Firefox have it display nothing. If it's IE have it display this image. http://homepage.mac.com/daines88/.Public/Ben/firefox.png and have the image linked to http://getfirefox.com
Grover
Aug 22, 2006, 09:56 PM
This will give you the idea. It works with IE for Mac but I haven't tested it using IE on Windows so you might have to massage it a bit for that.
There are lots of ways to go about the actual showing of the image. I've done what I thought would be the simplest to understand if you're just learning. The image and the link are there in the HTML markup but wrapped in a <div> tag that's hidden until it's made visible by the script.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<script type="text/javascript">
function checkUserAgent()
{
var isIE = navigator.userAgent.indexOf("MSIE") > 0;
if (isIE == true)
{
var linkContainer = document.getElementById("getFireFoxLink");
if (linkContainer)
{
linkContainer.style.display = "block";
}
}
}
</script>
</head>
<body onload="checkUserAgent()">
<div id="getFireFoxLink" style="display: none;">
<a href="http://www.getfirefox.com">
<img src="http://homepage.mac.com/daines88/.Public/Ben/firefox.png" border="0">
</a>
</div>
</body>
</html>
Benjamindaines
Aug 24, 2006, 06:18 PM
This will give you the idea. It works with IE for Mac but I haven't tested it using IE on Windows so you might have to massage it a bit for that.
There are lots of ways to go about the actual showing of the image. I've done what I thought would be the simplest to understand if you're just learning. The image and the link are there in the HTML markup but wrapped in a <div> tag that's hidden until it's made visible by the script.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<script type="text/javascript">
function checkUserAgent()
{
var isIE = navigator.userAgent.indexOf("MSIE") > 0;
if (isIE == true)
{
var linkContainer = document.getElementById("getFireFoxLink");
if (linkContainer)
{
linkContainer.style.display = "block";
}
}
}
</script>
</head>
<body onload="checkUserAgent()">
<div id="getFireFoxLink" style="display: none;">
<a href="http://www.getfirefox.com">
<img src="http://homepage.mac.com/daines88/.Public/Ben/firefox.png" border="0">
</a>
</div>
</body>
</html>
Thanks, is there a way to make that work with Myspace, when I add it it just comes up as text when the profile is viewed.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.