Solved

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

Posted on 2010-09-24
3
344 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

805 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