Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 根据链接显示iframe内容_Javascript_Html - Fatal编程技术网

Javascript 根据链接显示iframe内容

Javascript 根据链接显示iframe内容,javascript,html,Javascript,Html,我的页面中有一个iframe,我想根据选择的链接(锚定标记)显示内容。我希望使用javascript实现这一点 我的疑问是: 如何检索已选择的锚定标记 如果我从anchor标记中的onclick()函数调用javascript,并且没有添加href属性,那么anchor标记(link)将丢失它的hyperlink属性。那么,在这种情况下如何添加href属性呢 为iframe指定一个名称属性,即: <iframe src="startpage.html" name="content">

我的页面中有一个
iframe
,我想根据选择的链接(锚定标记)显示内容。我希望使用javascript实现这一点

我的疑问是:

  • 如何检索已选择的锚定标记
  • 如果我从anchor标记中的onclick()函数调用javascript,并且没有添加href属性,那么anchor标记(link)将丢失它的hyperlink属性。那么,在这种情况下如何添加href属性呢

  • 为iframe指定一个
    名称
    属性,即:

    <iframe src="startpage.html" name="content"></iframe>
    

    瞧!也不使用JS。
    <a href="nextpage.html" target="content">Next Page</a>