I'm fairly new to javascript so please forgive my errors. I want to
put a statement on a web page to let the user bookmark the page. I've
seen several different versions of this - but I can't make mine work
in IE. Here is the code:
<script language="JavaS cript" type="text/javascript">
<!--
function cknav(){
var IEstring = "<a
href='javascrip t:window.extern al.addFavorite( 'http://la.fooweb.com', 'LA
Homepage')";
IEstring += "><\/a>" ;
// IEstring += ";' title='Add to Favorites '><\/a>" ;
// IEstring += "(location.href ,document.title );' title='Add to
Favorites'>Favo rites<\/a>" ;
var NSstring = "Click [Ctrl + D] ";
var OPstring = "Click [Ctrl + T]";
var NSOPstring = "by returning to the main page and "
var OTHstring = "Bookmark this page!"
var whichString = OTHstring ;
var agt = navigator.userA gent.toLowerCas e();
var app = navigator.appNa me.toLowerCase( );
var ieAgent = agt.indexOf('ms ie');
var nsAgent = app.indexOf('ne tscape');
var opAgent = app.indexOf('op era');
// How do I get IE to execute this ?? it doesn't seem to do
anything.
if (ieAgent!= -1) { whichString = IEstring;
document.write( whichString);
alert(whichStri ng) }
else if (nsAgent!= -1){ whichString += NSOPstring + NSstring;
alert(whichStri ng) }
else if (opAgent!= -1){whichString += NSOPstring + OPstring;
alert(whichStri ng) }
}
-->
</SCRIPT>
</head>
<body>
<table width="80%" frame="border" cellspacing="3" cellpadding="3"
border="4" bgcolor="#fffff f" align="center" summary="Statem ent">
<tbody><tr>
<td>
<br />
<!-- Try One - IE only , gives an eror -->
<h1 class="c1"><fon t size="+2" color="#ff0000" ><b>New Web
Address.</b></font><br /><br />
<font size="+1" color="#000000" > If you got here by the
http://nu.net/lanet link, you were redirected the NEW home
of LA http://la.fooweb.com. <U>
<span style='color:re d;cursor:hand;' >
<a
href="javascrip t:window.extern al.AddFavorites ('HTTP://URL.COM','SITEN AME')">Bookmark
Me</a>
</span></u>
<!-- Try 2 - Great for non IE but need to know how to make IE do the
bookmark in the script -->
<br />
<h1 class="c1"><fon t size="+2" color="#ff0000" ><b>New Web
Address.</b></font><br /><br />
<font size="+1" color="#000000" > If you got here by the
http://nu.net/lanet link, you were redirected the NEW home
of LA <a
href="http://la.fooweb.com"> http://la.fooweb.com</a>. <U>
<span style='color:re d;cursor:hand;'
onClick=cknav() >Bookmark this address.</span></u>
</font><br />
</h1>
</td>
</tr>
</tbody>
</table><!-- End of page content -->
</body>
</html>
TIA
Stephen
put a statement on a web page to let the user bookmark the page. I've
seen several different versions of this - but I can't make mine work
in IE. Here is the code:
<script language="JavaS cript" type="text/javascript">
<!--
function cknav(){
var IEstring = "<a
href='javascrip t:window.extern al.addFavorite( 'http://la.fooweb.com', 'LA
Homepage')";
IEstring += "><\/a>" ;
// IEstring += ";' title='Add to Favorites '><\/a>" ;
// IEstring += "(location.href ,document.title );' title='Add to
Favorites'>Favo rites<\/a>" ;
var NSstring = "Click [Ctrl + D] ";
var OPstring = "Click [Ctrl + T]";
var NSOPstring = "by returning to the main page and "
var OTHstring = "Bookmark this page!"
var whichString = OTHstring ;
var agt = navigator.userA gent.toLowerCas e();
var app = navigator.appNa me.toLowerCase( );
var ieAgent = agt.indexOf('ms ie');
var nsAgent = app.indexOf('ne tscape');
var opAgent = app.indexOf('op era');
// How do I get IE to execute this ?? it doesn't seem to do
anything.
if (ieAgent!= -1) { whichString = IEstring;
document.write( whichString);
alert(whichStri ng) }
else if (nsAgent!= -1){ whichString += NSOPstring + NSstring;
alert(whichStri ng) }
else if (opAgent!= -1){whichString += NSOPstring + OPstring;
alert(whichStri ng) }
}
-->
</SCRIPT>
</head>
<body>
<table width="80%" frame="border" cellspacing="3" cellpadding="3"
border="4" bgcolor="#fffff f" align="center" summary="Statem ent">
<tbody><tr>
<td>
<br />
<!-- Try One - IE only , gives an eror -->
<h1 class="c1"><fon t size="+2" color="#ff0000" ><b>New Web
Address.</b></font><br /><br />
<font size="+1" color="#000000" > If you got here by the
http://nu.net/lanet link, you were redirected the NEW home
of LA http://la.fooweb.com. <U>
<span style='color:re d;cursor:hand;' >
<a
href="javascrip t:window.extern al.AddFavorites ('HTTP://URL.COM','SITEN AME')">Bookmark
Me</a>
</span></u>
<!-- Try 2 - Great for non IE but need to know how to make IE do the
bookmark in the script -->
<br />
<h1 class="c1"><fon t size="+2" color="#ff0000" ><b>New Web
Address.</b></font><br /><br />
<font size="+1" color="#000000" > If you got here by the
http://nu.net/lanet link, you were redirected the NEW home
of LA <a
href="http://la.fooweb.com"> http://la.fooweb.com</a>. <U>
<span style='color:re d;cursor:hand;'
onClick=cknav() >Bookmark this address.</span></u>
</font><br />
</h1>
</td>
</tr>
</tbody>
</table><!-- End of page content -->
</body>
</html>
TIA
Stephen
Comment