Home >Web Front-end >HTML Tutorial >document.getElementByIdx('contents').src=para does not work. Please check if I am doing this right? _html/css_WEB-ITnose

document.getElementByIdx('contents').src=para does not work. Please check if I am doing this right? _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:55:121353browse

e1f4ff64491df66c6185f6e73063b5a3
100db36a723c770d327fc0aef2ce13b1
93f0f5c25f18dab9d176bd4f6de5d30e
b2386ffb911b14667cb8f0f91ea547a7 Ato Processor D2000 and N2000 Series6e916e0f7d1e588d4f442bf645aedb2f
931450ca460d9e2956ce5f1057a3b31c
2fab885475e406efad0325e52a7cbf4d
fe62bdad80fddbba1df8c9af7f855504
74a74246ad8859d3acdb4b7d6dab3490
5709ee10c506412edb1946b194dea934
4a3a49cc0993a0125d55ef6af37be1ef
9c3bca370b5104690d9ef395f2c5f8d1

086e2ebc55811bfff6024d17e69dc86f
e4b994db3fd2792fd008a18862cab807
ef12c862b3210b396290005821a58deb
eb5f059992a0ae0ef16884cb75644e40 

9bc988c8d379612a3b235e5490d962db  
 var n=self.location.href.indexOf("?")  
 if(n>0)   
  {    
  var para=self.location.href.substr(n 1)   
  document.getElementByIdx("contents").src=para
  }
2cacc6d41bbb37262a98f745aa00fbf0 
73a6ac4ed44ffec12cee46588e518a5e 

我想要根据url传递的参数来设置frame的源


回复讨论(解决方案)

url 带问号吗
alert( para)看下这个是不是你要的

带问号的 url为file:////home/wangcb/htmlc/main.html?main-html.html#1

带问号的 url为file:////home/wangcb/htmlc/main.html?main-html.html#1


var para=String(self.location.href).substr(n 1)   

还是没用呀 按你的改了还是没效果 蛋疼

还是没用呀 按你的改了还是没效果 蛋疼


 var n=self.location.href.indexOf("?")  
 if(n>0)   
  {    
  var para=self.location.href.substr(n 1)   
  document.getElementById("contents").src=para
  }

??这没区别把???

??这没区别把???

getElementById 写错了

e1f4ff64491df66c6185f6e73063b5a3
100db36a723c770d327fc0aef2ce13b1
93f0f5c25f18dab9d176bd4f6de5d30e
b2386ffb911b14667cb8f0f91ea547a7Series6e916e0f7d1e588d4f442bf645aedb2f
9c3bca370b5104690d9ef395f2c5f8d1

086e2ebc55811bfff6024d17e69dc86f
92c2b2eb925383b5ba42590fd7dbf9c1
2e7a9d2d06b1fac95fa132586ae7f9f5
eb5f059992a0ae0ef16884cb75644e40 

9bc988c8d379612a3b235e5490d962db   
  document.getElementById("contents").src="http://www.sina.com"
2cacc6d41bbb37262a98f745aa00fbf0
73a6ac4ed44ffec12cee46588e518a5e
这样也不行 ,,你复制下来跑跑

8b05045a5be5764f313ed5b9168a17e6
100db36a723c770d327fc0aef2ce13b1
93f0f5c25f18dab9d176bd4f6de5d30e
b2386ffb911b14667cb8f0f91ea547a7Series6e916e0f7d1e588d4f442bf645aedb2f
9c3bca370b5104690d9ef395f2c5f8d1

f5ce95737cc88f7ad2ae97968cd9a21c
6a5bfd705230a447f00ada8201c13e48
eb5f059992a0ae0ef16884cb75644e40

2d0dde566e229391474f8e4890958dc3
document.getElementById("contents").src="http://www.sina.com"
2cacc6d41bbb37262a98f745aa00fbf0
73a6ac4ed44ffec12cee46588e518a5e
like this It doesn’t work, you can copy it and run it


f900b4fc197b16ab214eecf015bb6bd2 The script code after the tag will not be executed

 <!DOCTYPE html> <html> <head> <title>Series</title><script type="text/javascript">window.onload = function (){document.getElementById("contents").src="http://www.sina.com"}</script> </head> <frameset cols="350,*"> <frame id="links" class="links" name="links" src=""/> <frame id="contents" class="contents" name="contents" src="" /> </frameset>  </html> 

The 9th floor is the correct answer. Thank you very much.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn