Sunday, January 20, 2013

JavaScript alert box, How to Display a Alert Message in JavaScript


it's Very Easy To Display alert box in JavaScript Using JavaScript alert() method


Display JavaScript alert box on Page Load

<script type="text/javascript">
    window.onload=function(){
        alert('JavaScript alert box on Page Load');
    }
</script>


Display JavaScript alert box when user Click on a Link

Thursday, January 17, 2013

JavaScript onload Redirect to Another Page

Using JavaScript onload Event We can ask JavaScript to redirect to another page.

Add following JavaScript redirect code to head section in You’re Web page.

<script type="text/javascript">
        window.onload = auto_redirect;
        function auto_redirect() {
            var url_redirect = "www.ccnaq.blogspot.com";
            window.location = url_redirect;
        } 
</script>


In Above Example first we ask JavaScript to perform a function call auto_redirect in window.onload Event.

Then in auto_redirect function we create variable name redirect _url and assign url of the page we want to redirect and finally we redirect page using JavaScript window.location Object

Javascript alert new line | line break in javascript alert

<script type="text/javascript">
function alert_new_line()
{
alert("This is First Line\nThis is Second Line");
}
</script>

Javascript alert new line, line break in javascript alert