JS Gets the SRC instance of the IFRAME

Source: Internet
Author: User

<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>js Obtain the SRC example of the IFRAME </title>
<a href= "Web effects: Test ();" > Get </a>
<div id= "xxx" ><iframe src= "http://www.baidu.com" height= "" width= "100%" ></iframe></div>
<script type= "Text/javascript" >
function test (box) {
var re=/s+src= "([^"]+) "/;
var Src=document.getelementbyid (box). Innerhtml.match (re);
SRC=SRC?SRC[1]: "";
alert (SRC);
Test ("xxx");

If you operate freely inside an IFRAME, you can't assign a value to IFRAME.SRC.
In other words, in fact, the value of the way is existing, or the first assignment of their own, the external free link is still unable to obtain

Instance Code two

<script language= "JavaScript" >
function Test () {
Tmps tutorial rc=document.all.iftest.src;
alert (TMPSRC);
function Gogo (IFSRC) {

<table width= "100%" border= "0" cellspacing= "0" cellpadding= "0" height= "100%" >
&LT;TD height= "258" colspan= "2" >
<div align= "center" ><iframe name= "Iftest" id= "Iftest"
border=0 frameborder=0 framespacing=0 height=400marginheight=0
Marginwidth=0 noresize Scrolling=no
Src= "http://www.aimeige.com.cn/" width=400 vspale= "0" ></iframe></div>
&LT;TR align= "center" >
<input type= "Submit" name= "Submit" value= "to Sina" onclick= "Gogo (' Http://www.111cn.net ')" >
<input type= "Submit" Name= "Submit2" value= "to Sohu" onclick= "Gogo (' Http://www.111cn.net ')" >
&LT;TD colspan= "2" >
<div align= "center" ><a href= "javascript:;" onclick= "Test ()" > Show address </a></div>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.