If you want to disable going back in the previous page, I am going to show you very easy method to do this:
Suppose you are in Page 1 and go to page 2. If you want to go back to page 1 , you are able to go. But now, if you want to disable that going back features, add the following script in the body tag of the page 1:
body onload=”if(history.length>0)history.go(+1);”
This works only for IE and not for Mozilla Firefox. For Mozilla do this:
add this script within head:
function noBack()
{
window.history.forward()
}
noBack();
window.onload=noBack;
window.onpageshow=function(evt)
{
if(evt.persisted)noBack()
}
window.onunload=function()
{
void(0)
}
It works not only with Firefox but also with IE, Safari, Opera.
Wednesday, April 15, 2009
Sunday, March 15, 2009
Close the popup image when click on it
To close the popped up image when click on , do the following steps:
Create ShowImage.aspx page and add a image control with onclick property like:
asp:Image ID="Image1" runat="server" onclick = "window.open('','_self');window.close();"
And in the page load of ShowImage.aspx do this way:
if (Request.QueryString["image"] != null)
{
Image1.ImageUrl = Request.QueryString["image"];
}
Now, on the parent page write this script:
var Popup;
function popUp(url)
{
Popup = window.open(url, "Popup", 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=100,height=100,left = 490,top = 262');
Popup.focus();
}
function ChangeImg(obj)
{
//Show in popup
var radio = obj.getElementsByTagName("input");
for (var i=0;i less than radio.length;i++)
{
if (radio[i].checked)
{
popUp("ShowImage.aspx?image=images/" + radio[i].value + ".jpg");
}
}
}
Note: Use the general sign for 'Less than' in the for loop. I am unable to publish here because it acts like HTML tags and won't let me go.
Create ShowImage.aspx page and add a image control with onclick property like:
asp:Image ID="Image1" runat="server" onclick = "window.open('','_self');window.close();"
And in the page load of ShowImage.aspx do this way:
if (Request.QueryString["image"] != null)
{
Image1.ImageUrl = Request.QueryString["image"];
}
Now, on the parent page write this script:
var Popup;
function popUp(url)
{
Popup = window.open(url, "Popup", 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=100,height=100,left = 490,top = 262');
Popup.focus();
}
function ChangeImg(obj)
{
//Show in popup
var radio = obj.getElementsByTagName("input");
for (var i=0;i less than radio.length;i++)
{
if (radio[i].checked)
{
popUp("ShowImage.aspx?image=images/" + radio[i].value + ".jpg");
}
}
}
Note: Use the general sign for 'Less than' in the for loop. I am unable to publish here because it acts like HTML tags and won't let me go.
Wednesday, February 25, 2009
Images changing when clicking the radiobutton on the radiobutton list
If you have a ASP.NET C# form and use a radiobutton list. Suppose there are 4 radiobutton on the list.Default, no images loaded and when click the first radiobutton in the list, it displays a "1.jpg" and when click second radiobutton changes the image and so on...
For this, use the onclick function of the radiobuttonlist.
onclick = "ChangeImg(this);
and try this javascripts:
var Popup;
function popUp(url)
{
Popup = window.open(url, "Popup", 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=100,height=100,left = 490,top = 262');
Popup.focus();
}
function ChangeImg(obj)
{
//Show in popupvar radio = obj.getElementsByTagName("input");
for (var i=0;i less than radio.length;i++)
{
if (radio[i].checked)
{
popUp("images/" + radio[i].value + ".jpg");break;
}
}
}
For this, use the onclick function of the radiobuttonlist.
onclick = "ChangeImg(this);
and try this javascripts:
var Popup;
function popUp(url)
{
Popup = window.open(url, "Popup", 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=100,height=100,left = 490,top = 262');
Popup.focus();
}
function ChangeImg(obj)
{
//Show in popupvar radio = obj.getElementsByTagName("input");
for (var i=0;i less than radio.length;i++)
{
if (radio[i].checked)
{
popUp("images/" + radio[i].value + ".jpg");break;
}
}
}
Sunday, February 1, 2009
Auto close Popped up images after certain time
If you want to close your pop up image after 10 sec. just follow me:
Add a javascript function to the popup page
function Close()
{
window.close();
}
And to the body tag onload event add this
onload = "setTimeout('Close();', 10000)"
it will close the popup after 10 secs.
Add a javascript function to the popup page
function Close()
{
window.close();
}
And to the body tag onload event add this
onload = "setTimeout('Close();', 10000)"
it will close the popup after 10 secs.
Subscribe to:
Posts (Atom)