javascript print script - window.print()
The JavaScript print function window.print() will print the current webpage when executed. In this example script, we will be placing the function on a JavaScript button that will perform the print operation when the onClick event occurs.
HTML & JavaScript Code:
<form> <input type="button" value="Print This Page" onClick="window.print()" /> </form>
Display:
If you click this button you should be prompted with whatever application your computer uses to handle its print functionality.
javascript window.location
Control over what page is loaded into the browser rests in the JavaScript property window.location. By setting window.location equal to a new URL, you will in turn change the current webpage to the one that is specified. If you wanted to redirect all your visitors to www.google.com when they arrived at your site, you would just need the script below:
HTML & JavaScript Code:
<script type="text/javascript"> <!-- window.location = "http://www.google.com/" //--> </script>
No comments:
Post a Comment