sunlover
07-05-2003, 12:35 PM
Help!! I am very new to Javascript and need to know how to create hyperlinks using javasript. I have created an external .js file and need to implement it there. Thanks for the help.
|
Click to See Complete Forum and Search --> : external .js file sunlover 07-05-2003, 12:35 PM Help!! I am very new to Javascript and need to know how to create hyperlinks using javasript. I have created an external .js file and need to implement it there. Thanks for the help. Greelmo 07-05-2003, 12:38 PM try this... <script type="text/javascript" src="xxx.js"> www.w3schools.com Jona 07-05-2003, 12:49 PM Originally posted by sunlover Help!! I am very new to Javascript and need to know how to create hyperlinks using javasript. I have created an external .js file and need to implement it there. Thanks for the help. Are you referring to using Javascript to make an HTML link? Perhaps you mean this... externalFile.js function writeLink(hRef, target, txt){ document.write("<a href=\""+hRef+"\" target=\""+target+"\">"+txt+"</a>"); } Anypage.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html lang="en-us"> <head><title>My page</title> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> </head><body> <p>Here is some text, and here is a <script type="text/javascript"><!-- writeLink("www.yahoo.com","_self","link"); //--></script>!</p> </body></html> Try putting these pages online and testing them to see the result of the function I've provided, if you do not understand it completely. [J]ona sunlover 07-05-2003, 01:20 PM I am trying to create html links to other pages in my web site using an external .js file. What I need to know is what is the javascript code I need to write to call them. For example I need to link to a page called toys.html. How would I write that. I also need to create a link to my email address using javascript code. Any help I can get I would appreciate. Greelmo 07-05-2003, 01:23 PM oh okay... <script type="text/javascript"> function fnclink(page) { window.location=page; } </script> and the html if you want the link to be text <font onClick="fnclink('toys.html');" onMouseover="this.style.cursor='hand';">CLICK HERE!!!</font> Jona 07-05-2003, 01:24 PM I've just showed you how. document.write("<a href='toys.html'>Toys</a>"); document.write("<a href='mailto:you@yoursite.com'>Email me</a>"); [J]ona webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |