Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.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 如何使用引导打开模式中的所有链接_Javascript_Jquery_Html_Twitter Bootstrap - Fatal编程技术网

Javascript 如何使用引导打开模式中的所有链接

Javascript 如何使用引导打开模式中的所有链接,javascript,jquery,html,twitter-bootstrap,Javascript,Jquery,Html,Twitter Bootstrap,我希望能够在一个模式中打开页面上的所有链接 以下是一个例子: <a href="http://google.com.au">Google AU</a> <a href-"http://google.com">Google US</a> <a href="https://www.google.co.jp>Google JP</a> 如果没有在所有模式中编码,这些链接将无法工作,那么可以使用Javascript自动将页面上的所

我希望能够在一个模式中打开页面上的所有链接

以下是一个例子:

<a href="http://google.com.au">Google AU</a>
<a href-"http://google.com">Google US</a>
<a href="https://www.google.co.jp>Google JP</a>
如果没有在所有模式中编码,这些链接将无法工作,那么可以使用Javascript自动将页面上的所有链接打开到模式中吗


谢谢

首先,您应该创建一个空模式,内容将根据单击的链接填充。下面的Javascript应该有助于实现这一点。我没有测试过它,但它应该是这样的

$('a').click(function() { 
   $('#myModal .modal-content').html('<iframe src="' + $(this).attr('href') + '"></iframe>'); 
   $('#myModal').modal('show');
});
$('a')。单击(函数(){
$('#myModal.modal content').html('');
$('myModal').modal('show');
});

这篇文章可能会有所帮助,但从v3.3开始,它似乎已被弃用。我也尝试过使用jQuery负载,但运气不好。这似乎也很有希望@KiranShakya
$('a').click(function() { 
   $('#myModal .modal-content').html('<iframe src="' + $(this).attr('href') + '"></iframe>'); 
   $('#myModal').modal('show');
});