Search   Articles   Dev Forums   Personalize   Favorites   Member Login   ASP.Net Hosting
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Sunday, February 19, 2006

Search Directory
Trusted by over 7 million customers!
ASP.NET
VB.Net
C-Sharp
SQL Server
 
More Partners >>

Shake the browser window using JavaScript

Author: DevASP
Download Source Code : 555_ShakeBrowserWindow.zip

This article is about how you can shake the window of the user. This example is very much related to functionality in msn messenger. In msn messenger during chat when you BUZZ in the window.

  • Steps you will do. 
  • Start visual studio and create a new web application. 
  • Open the HTML design of your page and before closing the head tag add the following JavaScript function.

 

<script  language="JavaScript1.2">

 

function shake(n) {

if (parent.moveBy) {

for (i = 10; i > 0; i--) {

for (j = n; j > 0; j--) {

parent.moveBy(0,i);

parent.moveBy(i,0);

parent.moveBy(0,-i);

parent.moveBy(-i,0);

         }

      }

   }

}

</script>

 

 

Now add the following HTML code which will design your web page and call the above JavaScript function to shake the window.

 

<body MS_POSITIONING="GridLayout" bgcolor="#009999">

<center>

<form id="Form1" method="post" runat="server">

<input type="button" onClick="shake(2)" value="Shake Screen">

<H4>Dont forget to visit www.devasp.com</H4>

<a href="http://www.devasp.com">Devasp Team</a>

</form>

</center>

</ form>

</body>

 

Note that the value pass as parameter in the call of JavaScript function is used as duration of shaking the window, larger value means window will be shake for a long time.

 

Run you application and click the button to shake the window.





Article Comments
Name:  rajendra 
Good Code

Name:  Joshua Pelkala 
I was just lookign for a way to make this work exactly like you have it. Thank you.

Name:  Joshua Pelkala 
I was just lookign for a way to make this work exactly like you have it. Thank you.

Name:  kanagarajum 
Hai Friends

I done one Web Application using ASP.NET. I was uploaded

It is run on IE well.

and then It is run also other Browser but change the Alignment

so can u help me.......



Disclaimer - Privacy
Copyright © 2008 DevASP.net