javascript - open frame in new window - javascript

I have a page which is displayed in a frame as part of another site. I want to add a link to this page which will allow the user to open the page in a new window i.e. out of the frame. how do I do this?
I have tried using
Remove frame
but this did not work and only opened a new window with the address javascript:window.location.href

<input onclick="javascrpt:window.open(window.location.href);" type="button" value="your value here" />

Try :
<a href="javascript:window.location='whereiwanttogo.html';" target="_blank">

You can use this, it worked for me:
Printable version

Related

html window open-close by javascript

I want to close a window open by this javascript written in my landing html page .
window.open(location,"_self");
in the location html page I have a button where I tried with
<div onclick="javascript:self.close();">Xyyyy</div>
<div onclick="javascript:window.close();">Xxxx</div>
None of them work.
Note: my condition in I have to open the new window in the same place.
any help is appriciated
I did a search on the subject and this page is what i found.
html (not mine)
<input type="button" name="Quit" id="Quit" value="Quit" onclick="return quitBox('quit');" />
JavaScript (not mine)
function quitBox(cmd)
{
if (cmd=='quit')
{
open(location, '_self').close();
}
return false;
}
There is even a test page.
I did a search for a bunny rabbit too (which isn't mine either).
Updated : Mar-12-2015
I did a search on the subject and this page is what i found.
I did a test with this code and confirmed it is not supported. The comments are good reading.
JavaScript (not mine)
function close_window() {
if (confirm("Close Window?")) {
window.close();
}
}
html (not mine)
close
close
I don't get completely what you are trying to do but here are some tips:
window.open("https://slackoverflow.com");
is used to open an entirely new window(can be used to open local files as well ofc)
window.close();
window.close() Closes the tab.
<a target="_blank" href="http://your_url_here.html">Page yada yada</a>
And this can be used to open a link or page in a new tab. If you play around with these for a little itll start to catch on.
I hope some of these ideas help and will help you put together what you are trying to accomplish :)

window.open not opening window

I'm trying to open a page in a popup as opposed to new tab - but whichever browser I try this simply opens in a new tab, not popup.
<input type="button" value="new win" onclick="window.open('http://yahoo.com', 'width=500, height=400')" />
Any reason why?
Second parameter must be the window name:
<input type="button" value="new win"
onclick="window.open('http://yahoo.com', 'mywindow', 'width=500, height=400')" />
Working fine in Chrome and Firefox:
http://jsfiddle.net/DvMy5/2/
The second parameter should be name..Something like windowname
<input type="button" value="new win"
onclick="window.open('http://yahoo.com','windowname', 'width=500, height=400')" />
JSFiddle
onclick="window.open('http://yahoo.com', 'MyYahoo', 'width=500, height=400, toolbar=no, menubar=no')" />
window.open method is as follow.
window.open(URL,name,specs,replace)
Here is a good read Window open() Method
name Optional. Specifies the target attribute or the name of the
window. The following values are supported:
_blank - URL is loaded into a new window. This is default
_parent - URL is loaded into the parent frame
_self - URL replaces the current page
_top - URL replaces any framesets that may be loaded
name - The name of the window
Isn't this something controlled by the various browsers? Using target="_blank" opens in a new tab in Chrome, and my guess is that this also apply for Firefox, Opera, Safari and IE.
The problem is the 3rd argument to window.open. When you pass the 3rd argument, the browser will open a new window provided the window name(second argument is not already opened).
window.open("http://localhost:5000", "newWindow", "resizable")will open window but window.open("http://localhost:5000", "newWindow") will open a tab.

what do i need to open this in a popup or new window?

i'm making a bookmarklet to my website, and for now i have:
<a href="javascript:location.href='http://website.com/compartir_link.php?url='+encodeURIComponent(location.href)" >Save this</a>
wich works fine, the problem is when i try to open it in a new tab: it's like when i try to save: about:blank (in firefox)
And i want to be able to do this without loosing my current video, that's why i thouhgt about a poput, but a funcionally target="_blank" will work for me,
any suggestion?
thank you very mucho!
PD: this link will be saved as a bookmark in my Browser (maybe in my other webistes), Like facebook's bookmarklet/sharer
EDIT
After your replies i have this /js/file.js
jQuery("body").ready(function(){
jQuery(".keep_btn").click(function(event) {
event.preventDefault();
if(this.href=""){
this.href=document.URL;
}
window.open("http://website.com/API/public/compartir_link.php?url="+this.href,'about to keep', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=450,height=400');
});
});
And i could use it now in a iframe containg:
<a class="keep_btn" href="#" style="background-color:red;color:white;">keeps</a>
Which works for what i need (in case using in an external website)
But how can i use it in a regular so i can save it to my browser?
My best regards
Javascript call...
From Link:
Click Here to Open
From a button in the form:
<input type="button" value="Open the Window" onclick="openIt()" />
function openIt() {
w=window.open(linkUrl, reportName, "resizable=yes, directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,top=50,height=600, width=900");
}
If you're looking for a "pop up", I suggest something like the jQuery UI Dialog.

HTML - overRide statusbar link location display

when on Mouse Over state on a link the status bar shows the link's location in the status bar like in the following image...
is there a way to change\override this to show some desired text...
Most browsers will block attempts to change the status line by default for security reasons (phishing).
You can try it anyway:
link here
A second approach:
link here
Con: you can't open it in a new tabblad / window using Ctrl + click for example.
In ie9 method 1 does not have any effect. Method 2 also defeats the purpose of concealing info, by placing active file path in status bar, rather than customary interpolated uri:
C:\\\filepath\server\local\whatever
Perhaps there is a way to use method 2. Possibly a proxy link-file location intercept. For example:
click here
where c:\links\anylink links to c:\private\privatefile ...?
Further: 'Con: can't open link in new tab / new window' ... javascript?
This should work
<a href="/www.example.com/contact.html" onmouseover="window.status='Contact'" onmouseout="window.status=''">
If you must change the status, here is a cross browser solution that works:
<a href=".: This a link" onClick="window.location='myurl.html';return false">
Downside is that it requires Javascript
Change "This is a link" to required text" and change "myurl.html" to the path of the window file.
If you need to open a url using "_blank" you can create a function that opens a new window instead.
Unfortunately ".:" has to appear at the front of the text otherwise it will render as a url. Tested in IE9. (Firefox and other browsers render this differently
For other browser you could alternatively use "link:" then your url. Tested in Firefox.
NB: you can only change window.status for Opera, (and possible IE 6 and earlier), for security reasons as mentioned in other people's suggestions.
onmouseover or JavaScript are removed from ckeditor of blog sites when we try to input to a page more data next time. So I think, this method should work tested by me in Firefox browser.
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.btn {
border:none;
}
</style>
<form action="your url">
<input type="submit" class="btn" value="link here">
</form>
</body>
</html>

Close a bookmarklet after submitting form

This is related to question "Bookmarklet behind elements".
I want to either self close the iframe after form submission or if not possible, add a close button with the iframe to close it. my bookmarklet at the moment is
javascript:(function(){var iFrame=document.createElement('IFRAME');iFrame.src='http://www.yeongbing.com/testform/dd-formmailer/dd-formmailer.php';iFrame.style.cssText='display:block;position:absolute;top:5%;left:60%;width:40%;height:51%;overflow:hidden;';document.body.insertBefore(iFrame,document.body.firstChild);})();
I have tried the methods mentioned here but can't seem to work. Any suggestions?
Here's how you can close the iframe from your "Close Window" button.
First, give your iframe an id by adding "iFrame.id='foo';" to the end of your bookmarklet script:
javascript:(function(){var iFrame=document.createElement('IFRAME');iFrame.src='test2.html';iFrame.style.cssText='display:block;position:absolute;top:5%;left:60%;width:40%;height:51%;overflow:hidden;';document.body.insertBefore(iFrame,document.body.firstChild);iFrame.id='foo';})();
Then, in your iframe's source, change
<input type="button" onclick=window.close() value="Close Window"/>
to
<input type="button" onclick="parent.document.body.removeChild(parent.document.getElementById('foo'));" value="Close Window"/>

Categories

Resources