如何在单个iframe中显示点击的页面 [英] how to display clicked pages in single iframe

查看:80
本文介绍了如何在单个iframe中显示点击的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在单个iframe中显示点击的页面



嗨朋友们,



我想显示点击单个iframe中的页面,

我有单帧I帧,

在这个iframe之上我有网站链接在这个iframe中打开。



默认情况下,iframe里面应该有网页。



每当点击上面的链接时,它必须显示在这个iframe中。



所有点击链接的一个iframe。



请帮助。

谢谢。

解决方案

您可以为每个链接更改iframe的src属性。 iframe会为这些新位置加载内容并显示它们。



例如,您可以尝试使用此代码,



 <   iframe     src   =  >  <   / iframe   >  
< a href = http:// www.w3schools.com > 点击我< / a >





Inside您可以编写的JavaScript脚本用于处理事件(导航)的代码,然后在iframe中显示文档。



  //  确保你有jQuery  


' a' )。点击( function (){
// 阻止页面导航
event.preventDefault();
// 加载iframe内的页面(位于当前超链接的href)


'' iframe')。attr(' src'

how to display clicked pages in single iframe

Hi friends,

I want to display clicked pages in single iframe,
I have single I frame,
Above this iframe i have website links to open in this iframe.

by default, there should be webpage inside iframe.

whenever above links are clicked it must display in this iframe.

one iframe for all clicked links.

Please help.
Thanks.

解决方案

You can change the src attribute of the iframe for each of the link. Iframe would load the content for those new locations and will display them.

For example, you can give this code a try,

<iframe src=""></iframe>
<a href="http://www.w3schools.com">Click me</a>



Inside the JavaScript script you can write this code to handle the events (navigation) and then display the document inside the iframe.

// Make sure you're having jQuery


('a').click(function () { // prevent the page from navigating event.preventDefault(); // load the page (located at the href of current hyperlink) inside the iframe


('iframe').attr('src',


这篇关于如何在单个iframe中显示点击的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆