Page 1 of 1
fullscreen iframe from parent window
Posted: Tue Apr 06, 2010 6:33 pm
by Obadiah
I have an IFrame on my site that im using to display phpexcel pages. Im using javascript to change the src attribute...I was wondering....instead of putting another link for each page and setting the target to "_blank" for users to see the full view is there a way from the parent page to switch whatever the src is of the iframe and set the target to blank...that way its like a "veiw full screen" for the iframe
Re: fullscreen iframe from parent window
Posted: Tue Apr 06, 2010 8:52 pm
by jbulaswad
Obadiah,
If you run a window.open in JavaScript with the IFrame's source as the first parameter you will open a new window to that URL. See the following code for an example:
Code: Select all
<html>
<head>
<title>IFrame in New Window</title>
<script type="text/javascript">
/**
* Opens the iframe in a new window
*/
function runFullscreen() {
var objFrame = document.getElementById('myIFrame');
window.open(objFrame.src);
}
</script>
</head>
<body>
<button type="button" onclick="runFullscreen();">Fullscreen</button>
<br/>
<iframe id="myIFrame" src="http://www.google.com" style="width: 100%; height: 300px;" />
</body>
</html>
Re: fullscreen iframe from parent window
Posted: Wed Apr 07, 2010 11:44 am
by kaszu
As I understood you want to open iframe content in parent window using a link in iframe, if so:
Code: Select all
<a href="http://www.google.com" target="_parent">Open in parent</a>
<!-- or using javascript -->
<script type="text/javascript">
parent.window.location = "http://www.google.com";
</script>
**fixed*Re: fullscreen iframe from parent window*fixed**
Posted: Fri Apr 09, 2010 8:59 pm
by Obadiah
jbulaswad wrote:Obadiah,
If you run a window.open in JavaScript with the IFrame's source as the first parameter you will open a new window to that URL. See the following code for an example:
Code: Select all
<html>
<head>
<title>IFrame in New Window</title>
<script type="text/javascript">
/**
* Opens the iframe in a new window
*/
function runFullscreen() {
var objFrame = document.getElementById('myIFrame');
window.open(objFrame.src);
}
</script>
</head>
<body>
<button type="button" onclick="runFullscreen();">Fullscreen</button>
<br/>
<iframe id="myIFrame" src="http://www.google.com" style="width: 100%; height: 300px;" />
</body>
</html>
thanks bro...this here fit my needs perfectly...
