I want to open new tab window on some condition for example:
var temp=true
if(temp)
window.open('test.aspx');
My problem is window.open() in new tab should not subject to pop-up blockers.
I have tried window.open('viewReport.aspx', '_newtab' ); and window.open('viewReport.aspx', '_blank' );, but its always subject to pop-up blocker.
Please provide any solution.
Thanks.
Window.open will force opening a new tab with a given URL. This is called a Pop-Up.
You cannot control it.
Instead use javascript to simulate a windows by using ex. https://jqueryui.com/dialog/ or http://fancybox.net. Both works with ajax request so you can pull the html content from another page.
My problem is window.open() in new tab should not subject to pop-up blockers.
You might think that but the people writing web browsers do not.
You cannot open a new tab or window from JavaScript except in response to a user event.
The solution is to find some other way to present your information (such as providing the user with a link to it or placing it in the same page).
Create a jquery popup div in ‘on click trigger’ event, that pop up displays with opacity background and it will remains center the popup if you scrolling zoom out the browser and closing it fadeout, and also you can customize the content of the popup div for your cool website designs.
Working example: http://istockphp.com/jquery/creating-popup-div-with-jquery/#sthash.5HcIfl8n.dpuf
Related
See for example:
http://www.retailmenot.com/view/macys.com
When you click on one of the buttons, it both automatically opens a new tab, and pop out their modal window.
What are the possible ways to do this?
They seem to do both actions with Javascript. They actually do something that keeps the window in the current tab and not on the one that was opened. How is it done?
In general, Can I achieve these two actions (nevermind if focus is on new window) with a regular form submission with target=_blank the new tab, and some class to pop the modal window? What should the javascript look like?
Is there any way to do this without javascript at all?
Basically I'm looking for practices that are supported from IE8+, and cross browser compliant.
See this : http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_open
You can open your js modal also inside myFunction() function.
I am noticing that my share popups are being blocked on our application but not others.
Here is the code execution:
1.) User enters web page.
2.) User clicks on facebook or twitter or googleplus share icon
3.) Onclick event passes the request to an internal controller that saves some information and then redirects back to the originating webpage. This time, however, there is a request parameter that invokes the usage of opening a new window.
The code I have that invokes opening a new window is (for this example we will use facebook):
var url = 'https://www.facebook.com/sharer/sharer.php?u='+copyLink;
window.open(url,'newwindow','width=600,height=600');
Now, if i enable popups it works fine. The problem is the user has to enable popups every time.
Is it a server issue? What is the reason why on other apps they don't have blocked popups but for OUR APP we cannot use popups without enabling popups
Any help would be greatly appreciated.
From what I understand, your application attempts to open a popup window following a page load. The nytimes.com popup appeared in response to a mouse click.
There is an important difference between these two ways to open a popup: the latter follows a user-initiated action but the former does not. As a result, popup blockers will generally block the former but not the latter. A lot of users wouldn't be too surprised if a popup opened when they clicked a button, but they would be more irritated if a popup appeared when a page loaded. The fact that your popup was ultimately triggered by an action on another page doesn't matter - what happens if you manually add to the URL the extra parameter that opens the popup?
Here's an old page on MSDN on popup blockers. It may describe the popup blocker in IE6 (of all browsers), but I think it still provides a reasonable explanation of when popup blockers typically permit or block popups.
Would it be possible to open a popup for your share dialog before calling back to the server? I would expect that opening a popup in the onclick handler would work without needing to explicitly allow popups.
I haven't found a single answer able to tell me what's the right way to open a popup.
Times have changed, and popups have been mostly replaced with fancybox-like boxes. However, there are still times when popups are needed.
For those cases, I don't want my popup to be blocked by the browsers.
What's the right way to open a popup without it being blocked? Even if it opens a new tab in the browser. I just want my popup to be open, and have control of it from the parent or vice versa.
Popup blockers will block any popup, unless it is opened because of an user action.
If the user clicks on a link, and a popup is opened in the click listener of that link, the popup blocker knows the user want to open something and will not (or should not) block the popup.
What you cannot do:
open a popup when the page is opened or closed
open a popup after a certain interval
open a popup after something asynchronous happens
What you can do:
open a popup in the on click listener
using target="_blank" in a anchor tag
You can access both windows with JavaScript variables:
if you use window.open, the parent can have a reference to the popup by assigning the result of window.open to a variable. Check out this article at W3Schools.
If the popup needs to have access to the window who has opened it, you can use window.opener. Check out this question.
try this, it works for me
$('#myButton').click(function () {
var redirectWindow = window.open('http://google.com', '_blank');
redirectWindow.location;
});
Js fiddle for this is here https://jsfiddle.net/safeeronline/70kdacL4/2/
if you want to open new tab after ajax call see this fiddle http://jsfiddle.net/safeeronline/70kdacL4/1/
I am using window.open() method to open a page as a pop-up window for a link button click event.
But the poup-up window is having minimize,maximize,close(x) button.
I dont want those buttons. How can remove these buttons?
This is the method i am using,
window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,titlebar=no,scrollbars=1,resizable=0,width=450,height=310,left=500,top=350");
Tell me how can do this.
Regards,
Chirag Jain.
You can't.
If you want a popup style window without full window decorations you'd have to create a new overlay <div> on top of the existing content and fill that with content, perhaps using an <iframe>.
You can't do it from javascript alone. Think about it, if you could, then people could put it into code on web-pages and cause other people's computers to open windows they couldn't easily close.
Instead you'll have to look for an answer specific to whichever browser you're using to host this application, and change it on the computers of your users appropriately. Even then though I don't think you'll be in luck (with Firefox for example, I can see how to get rid of them on all browser windows, but not on just one).
In CRM2011 I have an IFrame that displays a custom ASPX page (a photo gallery). From that page when they click a photo, a new popup should appear with the photo in real size.
What do I have to do to make this work? I tried several methods, none of them are working. It works fine when I'm opening the page in a browser! When I click on a photo, the real sized photo opens in a new screen.
My methods with javascript are :
click => When I use that method, it opens a new window with the complete page that is shown in the IFrame. If the iframe is "http://myPage.aspx", it will open a new window with "http://myPage.aspx" instead of the photo....
<span onclick="window.open(....)">click</span> => Nothing Happens
click => Same happens like method 1
I've tried many other things, but none of them had the wanted effect...
Kind Regards,
Frederic
Thx for your reply.. But unfortunately, it doesn't work. It still opens the same page in a new browser while clicking on it in an IFrame, instead of a popup.
It even gives me a weird behavior when I click on it opened in a normal browser. It opens an popup, but it also opens a second screen with the page itself.
So I still haven't found a way to open it correctly from an IFrame.
Kind Regards,
Frederic
My problem is solved... Somebody has activated the "Restrict cross scripting" on the iframe on the CRM. It works like a charm now, when i deactivate that option!
Thx for the help!
I would change this code:
click
So that it has a target and the script is identified as JS:
click