Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 14, 2011 09:59 AM by madan535
Contributor
3229 Points
1180 Posts
Jan 14, 2011 08:08 AM|LINK
But got a browser issues
Its working fine in IE but not in Chrome
Star
14673 Points
1496 Posts
Jan 14, 2011 08:30 AM|LINK
Oh. I am very sorry. I haven't tested it in all browsers. It seems that click() method isn't supported by Chrome.
Please try the following instead:
protected void Button1_Click(object sender, EventArgs e)
{
close();
}
void close()
string script = @"
fireEvent(window.parent.document.getElementById('fancybox-close'), 'click');
function fireEvent(obj, evt) {
var fireOnThis = obj;
if (document.createEvent) {
var evObj = document.createEvent('MouseEvents');
evObj.initEvent(evt, true, false);
fireOnThis.dispatchEvent(evObj);
} else if (document.createEventObject) {
fireOnThis.fireEvent('on' + evt);
";
Page.ClientScript.RegisterStartupScript(
typeof(Page),
"close",
string.Format("<script type='text/javascript'>{0}</script>", script));
The JavaScript method fireEvent() is from Trying to get javascript to click a link when function is called. I have tested it in IE9, Chrome, FireFox and Safari.
Jan 14, 2011 09:57 AM|LINK
Thanks it woked
Jan 14, 2011 09:59 AM|LINK
The below is also working
Previously iam using Fancy Box version 1.3.3 Now changed to 1.3.4
I changed the script
string script = "parent.$.fancybox.close() ;";
It is also working in all browsers
madan535
Contributor
3229 Points
1180 Posts
Re: Redirect Problem
Jan 14, 2011 08:08 AM|LINK
But got a browser issues
Its working fine in IE but not in Chrome
Wenchao Zeng...
Star
14673 Points
1496 Posts
Re: Redirect Problem
Jan 14, 2011 08:30 AM|LINK
Oh. I am very sorry. I haven't tested it in all browsers. It seems that click() method isn't supported by Chrome.
Please try the following instead:
protected void Button1_Click(object sender, EventArgs e)
{
close();
}
void close()
{
string script = @"
fireEvent(window.parent.document.getElementById('fancybox-close'), 'click');
function fireEvent(obj, evt) {
var fireOnThis = obj;
if (document.createEvent) {
var evObj = document.createEvent('MouseEvents');
evObj.initEvent(evt, true, false);
fireOnThis.dispatchEvent(evObj);
} else if (document.createEventObject) {
fireOnThis.fireEvent('on' + evt);
}
}
";
Page.ClientScript.RegisterStartupScript(
typeof(Page),
"close",
string.Format("<script type='text/javascript'>{0}</script>", script));
}
The JavaScript method fireEvent() is from Trying to get javascript to click a link when function is called. I have tested it in IE9, Chrome, FireFox and Safari.
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework
madan535
Contributor
3229 Points
1180 Posts
Re: Redirect Problem
Jan 14, 2011 09:57 AM|LINK
Thanks it woked
madan535
Contributor
3229 Points
1180 Posts
Re: Redirect Problem
Jan 14, 2011 09:59 AM|LINK
The below is also working
Previously iam using Fancy Box version 1.3.3 Now changed to 1.3.4
I changed the script
void close()
{
string script = "parent.$.fancybox.close() ;";
Page.ClientScript.RegisterStartupScript(
typeof(Page),
"close",
string.Format("<script type='text/javascript'>{0}</script>", script));
}
It is also working in all browsers