js显示url地址内容

JavaScript08

js显示url地址内容,第1张

<iframe name="right" id="rightMain" src="" frameborder="no" scrolling="auto" width="100%" height="auto" allowtransparency="true"></iframe>

比如你的iframe的代码和上面类似, 那么在ajax返回的url可以这样用:

 document.getElementById('rightMain').src=url

你的url要显示在什么地方?

如果是显示在最后,可以在js里面追加html

比如:

var url = document.createElement('a')

url.href = 'http://xxxx'

url.innerText = url.href

document.body.appendChild(url)

设置或获取对象指定的文件名或路径。\x0d\x0a\x0d\x0aalert(window.location.pathname)\x0d\x0a\x0d\x0a\x0d\x0a设置或获取整个URL为字符串。\x0d\x0a\x0d\x0a\x0d\x0aalert(window.location.href)\x0d\x0a\x0d\x0a设置或获取与URL关联的端口号码。\x0d\x0a\x0d\x0aalert(window.location.port)\x0d\x0a\x0d\x0a\x0d\x0a设置或获取URL的协议部分。\x0d\x0a\x0d\x0aalert(window.location.protocol)\x0d\x0a\x0d\x0a\x0d\x0a设置或获取href属性中在井号“#”后面的分段。\x0d\x0a\x0d\x0aalert(window.location.hash)\x0d\x0a\x0d\x0a\x0d\x0a设置或获取location或URL的hostname和port号码。\x0d\x0a\x0d\x0aalert(window.location.host)\x0d\x0a\x0d\x0a\x0d\x0a设置或获取href属性中跟在问号后面的部分。\x0d\x0a\x0d\x0aalert(window.location.search)\x0d\x0a