Solved

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …

743 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

14 Experts available now in Live!

Get 1:1 Help Now