I am trying to open a URL in a new window.
The URL is opened in a new window but without any Menu and navigation controls.
JSFiddle: https://jsfiddle.net/Sahil_Gupta/nfuehqv1/2/
I am using JAVA and ZK in backend and using Script to run the code as:
Script jsScriptInitializer = new Script();
String js = "window.open('https://www.google.com', '_blank', 'location=no,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes');";
jsScriptInitializer.setContent(js);
jsScriptInitializer.setDefer(true);
jsScriptInitializer.setParent(event.getTarget().getParent().getParent());
I need all the navigation and menu controls as usual when I open a URL in another window.
How can I achieve this ?
Your code will work as desired in browsers other than Chrome. There has been an ongoing bug in Chrome which has turned into a feature request. You can read about it at: https://bugs.chromium.org/p/chromium/issues/detail?id=82522
As of Jan 2022, there is still no way to open a Seperate window with the standard toolbars. However, if you can accept the new window being in the form of a tab rather than a separate window, simply eliminating the third argument will open as a fully featured tab.
// open a new tab
window.open('https://www.google.com', '_blank');
Related
I'm a beginner in Jquery or Javascript so, this is what should be happening.
In a website(not mine nor have a control), I visited I want to click this html element below.
HTML
<a class="_ng0lj" href="http://example.com" rel="nofollow me noopener noreferrer" target="_blank">www.example.com</a>
This link should be opened in a new tab.
When the tab pops-up, will send that window BEHIND the rest of the browser windows.
Where I am:
For now, I am currently in the process of trying to get the link from the class=_ng0lj and store it on a var so that I could use this for the next function.
NEXT:
Execute a function to open this var with the link to a new browser window and send it to the rest of the browser windows.
Jquery
$('div a._ng0lj').click(function(){});
I did open the link but not on the new window plus I want to get the link for the other purposes that's why I want to know how I could grab the link and store it in a var.
Hope this makes any sense.
To get the link : $('a._ng0lf').attr('href')
To open a window in background :
var otherWindow = window.open('about:blank', '_blank');
otherWindow.blur();
window.focus();
otherWindow.location.href = href;
I am having a Proposal Builder Custom Formula(TEXT) using hyperlink on opportunity. When i click that i am trying to open a VF page in new window.
Hi, i need help on this salesforce task plzz.
My requirement is..
I opened Opportunity In IE and when i click Proposal Builder link on Opp, then that VF page should open in CHROME.
Any Suggestions or ideas plzzz..
Here is the Formula field i created:
HYPERLINK("https://mysalesforceorg.com/apex/cpq?opportunity_id="& Id &""e_id="& Id &"&Session_id="&$Api.Session_ID,"Proposal Builder","_blank")
CPQ is the VF Page to be opened when clicked.
Thankyou...
There is no way to force a browser to pass a URL to a different browser. It would be possible to create shortcuts on your desktop to open certain bookmarks in a specific browser, but what you are asking for is not possible. Once you're operating in a browser, it's going to handle any links/redirects/actions within itself (whether that be in the current tab, in a new tab, or in a new window).
With that said, there are certain extensions for Chrome that would allow an end user to render a page using an IE tab within Chrome...but there's no way for you as the developer to guarantee your users are going to do that.
I'm trying to create a web page that opens two separate browser tabs in the same window. However, using window.open appears to open two separate windows, instead of two browser tabs within the same new window.
I attempted to open http://en.wikipedia.org and http://jsfiddle.net in the same browser window, but each tab was opened in a separate window instead:
window.open("http://www.jsfiddle.net/", "newWindow", "height=200,width=200");
window.open("http://en.wikipedia.org/", "newWindow", "height=200,width=200");
What am I doing wrong here, and what is the correct way to open multiple tabs in a single new window using JavaScript?
It depends on browsers setting that usually is part of user preferences and there is no specific trick to force a browser to behave in certain way!
Try with this lines, it should work.
<a class="link1">Link 1</a>
<a class="link2">Link 2</a>
<script type="text/javascript">
$("a.link1").on("click",function(){
window.open('http://www.jsfiddle.net/','_blank');
});
$("a.link2").on("click",function(){
window.open('http://en.wikipedia.org/','_blank');
});
</script>
I think the ablove lines of code may not work in all the browsers, we can do it in other way by setting the target value for the anchor tag as follows.
$('a').click(function() {
$(this).attr('target', '_blank');
});
Opening a webpage URL in window or tab depends on user's preferences in browser settings. Modern browsers do not allow a web application or webpage to change this behavior. But you can create a browser add-on or extension to override user's browser settings and can open a page in a tab or window using the extension.
I have a link that when clicked replaces the current page with another through the default <a> element click behaviour, but which also calls a JavaScript function to open another page in a new window. I would like the new window opened from my JavaScript function to appear behind the current window but can't figure out how to do this. In actual usage, I am feeding click thrus to a database, the link that is controlled by the window.open statement. The other link is to the clients site in a new window. I want the clients site to appear on top.
My current code is as follows:
<script language="JavaScript" type="text/JavaScript">
function countClicks(a,b)
{
window.open("http://stackoverflow.com?id="+a+"&id2="+b, "_blank");
}
</script>
test
So for the example URLs shown above I would like the (original) window with Google to appear in front of the new window with StackOverflow, but the new window always opens in front.
Try using window.focus() at the end of your existing function:
function countClicks(a,b) {
window.open("http://stackoverflow.com?id="+a+"&id2="+b, "_blank");
window.focus();
}
That should bring the existing window back to the front, noting that behaviour may vary between browsers and depending on popup-blocking settings, etc.
Or you could just swap the two urls, i.e., put the StackOverflow url in the href with the appropriate query string specified directly rather than in JS, and put the Google url in the window.open() call.
Popup behavior varies based on browser/user settings. I haven't been able to replicate the open behind behaviour myself, but I believe what you're looking for is .focus().
Try:
window.open("http://stackoverflow.com?id="+a+"&id2="+b, "_blank").focus();
I have a friefox sidebar extension. If its opened by clicking on the toolbar icon I load it with a webpage ( that I have authored ). Now, if the user clicks on the link on the webpage ( thats loaded into the sidebar ) I want the linked webpage to open up in a new tab of the main window. I tried with this in my webpage markup:
<a target="_content" href="http://www.google.com">Google</a>
But the link opens up in the tab that has focus and not in a new tab.
Please help.
Thanks.
If you use target="_blank" instead, FF (version 3) should open a new tab for it. Haven't tried it from a sidebar, but it's worth giving a shot.
Actually, there is no way to load a webpage ( whose link was in another webpage loaded into the sidebar extension ) onto a new tab in the browser. The only way is to use javascript. That has to execute under privileged conditions ( meaning as part of an extension ) like below:
gBrowser.addTab("http://www.google.com/");
EDIT:
The above technique of adding a browser tab did not work in this case. According to this article code running in the sidebar does not have access to the main window. So first up I got access to the browser window before using gBrowser. Here is the code taken from the website that I used and works properly:
var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindow);
After I got access to the browser window I accessed gBrowser through the getBrowser function like below:
mainWindow.getBrowser().addTab("http://www.google.com/");
The opens up a new tab in the main window browser.
Google
This is more dependent on the browser that is being used. Firefox and Opera, and I'm sure the newest IE, display "new windows" as a new tab unless otherwise specified by user preference.