I want to open a new window in button click.I have used a code.
Response.Write("<script type='text/javascript'>detailedresults=window.open('YOURPAGE.aspx','_blank');</script>")
It is behaving like a pop up window,but it is not working in IE 7.0 & Chrome.Please help me to solve that issue.Thanks in advance.
In most modern browsers, the browser will prevent the pop-up if the javascript wasn't run as the result of a user action. Actions like onClick are ok, but script that executes as soon as the page loads will usually be blocked.
HTH,
Brian
Why not set the target to _blank on an anchor tag instead of a button? e.g.
<a href="yourpage.aspx" target="_blank" />
Does that work for you?
Due to the prevalence of very irritating adverts and attacks based around opening a popup window as soon as a page loads, most modern browsers will block them.
You can only have a popup if it is direct response to a user event (e.g. in an onclick handler).
You cannot trigger on at page load time.
Related
I'm trying to create a Chrome extension that features a browser action and a popup. I need to refresh the content I serve in the popup every time the user opens it, but since the on clicked event will not fire if a popup is assigned to the browser action, I don't know how to trigger the logic to refresh the content.
I'm trying to do this in the background page, but I understand that that might not be the best way. Does anybody have an idea of how to approach this?
Thanks for any help.
The popup is created from scratch every time the user opens it, so any javascript file you include using a <script> tag will be executed. You can include any logic you need there.
I have a web application, and I want to disable the Back button.
I read and found that I can open the browser without the navigation controls with the function window.open(...).
This is the code:
window.open (mywebappURL,"mywindow","status=1,toolbar=0");
I tried to put it in my Main.Master page, but I get an infinite loop and the new window is opened as a popup window of my application.
Does anyone knows where should I put this code to get my web application opened in a browser without navigation buttons?
Thanks,
Inbal.
try this on the link's onclick() event
function openPopup(){
var pathname = (window.location.pathname);
window.open(pathname+'somePopup.html','','width=800,height=450,resizable=yes,dependent,screenx=80,screeny=80,left=80,top=20,scrollbars=no');
return false;
}
and in the html
click me
To answer your question directly, make sure the window you're opening is a different URL than the window that's initially visited. So your visitor might arrive at www.example.com/index.html which then opens www.example.com/popup.html
If you open index.html again, the new copy will immediately open a popup, which will immediately open a popup, and there's your infinite loop.
However, as several people have commented already, this is generally discouraged. Among other disadvantages to this approach, popup blockers will likely interpret this as trying to launch a popup advertisement, forcing your visitors to recognize what's happened and change their settings.
I have a script where it opens a window for online application after executing some other scripts.
window.open() is not called on any click. It is getting called in a script and browser prevents the new window from appearing.
How to overcome this?
Here is the code:
window.open('/search/applyonline?jobid=".$jobDetails->getIdjob()."',
'applyurljob',
'height=550,\
width=800,\
toolbar=no,\
directories=no,\
status=no,\
menubar=no,\
scrollbars=yes,\
resizable=yes,\
left=200,\
top=250')
Popup blockers will block windows from being opened that are not in response to a click event. Therefore you can:
Ask your users to turn off their popup blocker (not nice).
Change your scripts to work in response to a link or button click.
Use fake windows such as a jQuery UI dialog.
What I mean is - when user clicks on some browser page reload/refresh button we do not want to reload page - we want to capture that event and call some function (for simple example one with some alert). I need it to work in IE6 and up and Chrome and Firefox3+ of course. How to do such thing (not using jQuery and other libs)?
It's not possible.
You can detect when an unload occurs, but you can't detect what caused the unload and you can't cancel it without the user's consent. For instance, typing a new address in the address box, clicking a link, submitting a form, selecting a bookmark or refreshing the page will all fire an onbeforeunload event.
You cannot. You can't change the operating system functionality from within any browser except IE.
I am trying to open a certain page from my default page.
All the code there is in the default page is:
<script type="text/javascript">
window.open("StartPage.aspx", "", "fullscreen=yes");
</script>
The problem is that the browser's popup blocker blocks this and I need allow the browser to open it.
I want to avoid this and that every one that will use my web application won't need to allow the popup blocker to open the page. I want to pass the popup blocker and open the page without permission.
Is there a way to do so?
Thanks
adamantium is right. a popup blocker would be pretty useless if it could be overridden by the code that's causing the popup. the best you can do is this:
<script type="text/javascript">
var myPopup = window.open("StartPage.aspx", "", "fullscreen=yes");
if(!myPopup)
alert('a popup was blocked. please make an exception for this site in your popup blocker and try again');
</script>
As others have stated, you simply can't. The browser is blocking that behavior. Another option would be to not use window.open but instead use a javascript component which can give you the same behavior.
You won't be able to do that. Its a user preference to block pop up windows and you have no control over that.
You can open popup using onclick event only. You can try submitting form with target="_blank" and action set to your url, but forefox blocked this, google chrome not.
I don't think that's impossible, everyday I see streaming pages opening popups all the time and mine's being blocked so it should be a way to bypass it