The script belwo works in IE, how do i get it to work in FireFox?

<script type="text/javascript" language="JavaScript">
<!-- JavaScript -->
<!-- Begin
mesg = "Welcome to WhiteCityCavaliers.com New Litter has just arrived....Ready for you after weaning!....More Love than you could expect from a puppy, Cavaliers love to please you....";
isNS = (navigator.appName == "Netscape")
isIE = (navigator.appName == "Microsoft Internet Explorer")
text = ("<i><font size=8>"+mesg+"</font></i>")
if (isNS) {
document.write(" text + ")}
else if (isIE) {
document.write("<MARQUEE BEHAVIOR=ALTERNATE DIRECTION=RIGHT>" + text.fontcolor("Aqua") + "</MARQUEE>")}
// End -->
</script>

Recommended Answers

All 7 Replies

Here and i hope this will help you in what you need...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>CrossBrowser Script</title>
<script type="text/javascript">
<!--
var browser = { ua : function(myBrowser) {
return navigator.userAgent.toLowerCase().indexOf(myBrowser); }, byName : function(myBrowser) {
return navigator.appName.toLowerCase().indexOf(myBrowser); } }

//-->
</script>
</head>

<body>
<div id="main">
<script type="text/javascript">
<!--
/* Note! This demo is not always reliable than it is, since there are many version of browser released in the market. 
  So you might as wel wanna check different version by providing special technique on getting specific version for every browser -- where you can apply appropriate script run... */
 
var mesg = '<p>Welcome to WhiteCityCavaliers.com New Litter has just arrived....<br>Ready for you after weaning!....<br>More Love than you could expect from a puppy, Cavaliers love to please you....</p>';

if ((browser.ua('opera') != -1) || (browser.byName('netscape') != -1)) {
document.write('<i><font size="8">' + mesg.fontcolor('blue') + '</font></i>'); }
else if ((browser.byName('microsoft internet explorer') != -1) || (browser.ua('msie') != -1)) {  document.write('<MARQUEE BEHAVIOR=ALTERNATE DIRECTION=RIGHT SCROLLDELAY=100 SCROLLAMOUNT=2>' + mesg.fontcolor('aqua') + '</MARQUEE>'); }
else { document.write('<p>Unsupported version of browser</p>'); }
//-->
</script>
</div>
</body>
</html>

Here and i hope this will help you in what you need...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>CrossBrowser Script</title>
<script type="text/javascript">
<!--
var browser = { ua : function(myBrowser) {
return navigator.userAgent.toLowerCase().indexOf(myBrowser); }, byName : function(myBrowser) {
return navigator.appName.toLowerCase().indexOf(myBrowser); } }

//-->
</script>
</head>

<body>
<div id="main">
<script type="text/javascript">
<!--
/* Note! This demo is not always reliable than it is, since there are many version of browser released in the market. 
  So you might as wel wanna check different version by providing special technique on getting specific version for every browser -- where you can apply appropriate script run... */
 
var mesg = '<p>Welcome to WhiteCityCavaliers.com New Litter has just arrived....<br>Ready for you after weaning!....<br>More Love than you could expect from a puppy, Cavaliers love to please you....</p>';

if ((browser.ua('opera') != -1) || (browser.byName('netscape') != -1)) {
document.write('<i><font size="8">' + mesg.fontcolor('blue') + '</font></i>'); }
else if ((browser.byName('microsoft internet explorer') != -1) || (browser.ua('msie') != -1)) {  document.write('<MARQUEE BEHAVIOR=ALTERNATE DIRECTION=RIGHT SCROLLDELAY=100 SCROLLAMOUNT=2>' + mesg.fontcolor('aqua') + '</MARQUEE>'); }
else { document.write('<p>Unsupported version of browser</p>'); }
//-->
</script>
</div>
</body>
</html>

That would be nice, could you explain how>

Another thing is the font size is now small and I can't seem to change it.
I am new to JS so I appericate any help.
Thanks

Wel i hope that this will finalized your issue.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>CrossBrowser Script</title>
<script type="text/javascript">
<!--
var browser = { ua : function(myBrowser) {
return navigator.userAgent.toLowerCase().indexOf(myBrowser); } }

//-->
</script>
</head>

<body>
<div id="main">
<script type="text/javascript">
<!--
/* So here's an example with some of the most commonly used browser in market today., */
 
var mesg = '<p>Welcome to WhiteCityCavaliers.com New Litter has just arrived....<br>Ready for you after weaning!....<br>More Love than you could expect from a puppy, Cavaliers love to please you....</p>';


/* Meant For Opera
  NOTE! That you can also use parseFloat(navigator.appVersion) to get series of version for Netscape/IE/Opera to lessen your work with your script.
  But its not as accurate as using RegExp to trap specific version, so i'll stick with Regular Expression if i want to get detailed version of every browser.  */

if ((browser.ua('opera') != -1) && (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent))) { 
var opversion = new Number(RegExp.$1);

opversion = (opversion >= 9  ) ? document.write('Your preferred statement if Opera9 is achieved') : alert('You are using Opera v' + opversion + '!'); }

// For FF 
else if ((browser.ua('firefox') != -1) && (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))) {
var ffversion = new Number(RegExp.$1); 

ffversion = (ffversion >= 3  ) ? document.write('Your preferred statement if Firefox3 (or better) is achieved') : alert('You are using Firefox ' + ffversion + '!'); }

// This is for IE
else if ((browser.ua('msie') != -1) && (/MSIE[\s](\d+\.\d+);/.test(navigator.userAgent)) || (/MSIE(\d+\.\d+);/.test(navigator.userAgent))) { 
var ieversion = new Number(RegExp.$1);
ieversion = (ieversion >= 8  ) ? document.write('Your preferred statement if Internet Explorer8 is achieved') : alert('You are using Microsoft Internet Explorer ' + ieversion + '!'); }

else { alert('You can still add more vendor names and as wel as vendor version\'s\nJust keep it clean and valid according to vendor names/version you choose to include!'); }

/* You still have other option asside from this example-- which i referred to as using the object detection method. 
And whichever method you choose, just be sure to choose one and what's best for your needs */ 

//-->
</script>
</div>
</body>
</html>

Great but could you please explain why I am unable to change the font type or size, when i change it in the code nothing happens.

Most of the problem is the only book i have on JS is dated 1996, and it has changed so much.. Appericate your help.

Ok its more appropriate if we will use CSS Rules to apply different presentations on your page. So here's what ive got

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>CrossBrowser Script</title>
<style id="int" type="text/css">
<!--
.default { font-size: 8pt; color: #006; }
.ie { font-size: 12pt; color: #05f; }
.op { font-size: 14pt; color: #f10; }
.ns { font-size: 16pt; color: #c0c; }
.ff { font-size: 18pt; color: #c0c; }
-->

</style>
<script type="text/javascript">
<!--
 
var mesg = '<p>Welcome to WhiteCityCavaliers.com New Litter has just arrived....<br>Ready for you after weaning!....<br>More Love than you could expect from a puppy, Cavaliers love to please you....</p>';

var marQuee = '<MARQUEE DIRECTION=RIGHT BEHAVIOR=ALTERNATE SCROLLAMOUNT=2 SCROLLDELAY=300>This is a JavaScript Demo!</MARQUEE>';

function fillMe(iE) {
if (iE) { 
document.write(marQuee); }
else { document.write(mesg); }
} 
//-->
</script>
</head>
<body>
<div id="main" className="default">
<p>
<script type="text/javascript">
<!--
fillMe((document.all || window.attachEvent));

/* Now on this example i will use the object detection method to apply different presentation on this document. */

/* Meant for OPERA Browser */
if (window.opera) {
document.getElementById('main').className = 'op'; }

/* Detects Firefox browser */
else if (window.iterator || Array.every) {
document.getElementById('main').className = 'ff'; }

/* Detects IE Browser */
else if (document.all || window.attachEvent) {
document.all['main'].className = 'ie'; }

else {
/* Detects Netscape Browser */ document.layers['main'].className = 'ns'; }
//-->
</script>
</p>
</div>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.