How to Open a Second Web Site With Java Script
Javascript is client-side code that lets you control how web pages behave after the initial page code loads in the web browser window. You can use Javascript for opening new websites. This type of coding is helpful when you want to show a new window for a website ad or when the user clicks a button to view a new website. Instead of setting up the page so the reader must leave your site, you can program it so that a new website opens in a second window or tab.
Instructions
-
-
1
Right-click the HTML file where you want to open a new window. Select "Open With" then double-click "Notepad" and click "Open." The HTML code opens in your editor.
-
2
Create a "script" block in your HTML code. Type the following code after the "<head>" tag but before the closing "</head>" tag:
<script type="text/javascript"> </script>
-
-
3
Type the following code in the script code you created in step two:
window.open("NewWebsite.com")
Replace "NewWebsite.com" with the website you want to open on the user's browser.
-
4
Click the "File" main menu item and click "Save." The changes save to the HTML page. To test the Javascipt, double-click the file. After the file loads in your browser, the new window opens and navigates to the secondary website.
-
1