Solved

How can I dynamically display an external page in an iframe?

Posted on 2010-09-24
3
342 Views
Last Modified: 2012-05-10
I'd like to have a single page at my site where I could dynamically display an iframe of an external URL with my branding above it, so that a URL like http://www.mysite.com/view.php?URL=www.cnn.com would automatically display in this layout:

http://cl.ly/6b7e8801e41034045e22

the way StumbleUpon's top banner looks (doesn't have to be that url structure)

Is there a way to do this in PHP or jQuery?

Thanks,

Nathan
0
Comment
Question by:nbierm65
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 33753416
SImple JS :

      window.onload= function() {
            document.getElementById("myframe").src = "http://" + gup("URL");
      }

Where GUP are here : http://www.netlobo.com/url_query_string_javascript.html

test page :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">

	window.onload= function() {
		document.getElementById("myframe").src = gup("URL");
	}

	function gup( name ) {
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( window.location.href );
	  if( results == null )
		return "";
	  else
		return results[1];
	}

</script>
</head>
<body>
<iframe id="myframe" width="1024" height="800"></iframe>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:nbierm65
ID: 33753591
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33753628
You're welcome! Thanks for the points!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now