使用javascript执行链接 [英] Execute link using javascript
本文介绍了使用javascript执行链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
点击以下链接可打开视频:
The following link opens a video when clicked:
<a href="<?php echo $rows['image1'] ; ?> " rel="vidbox" title="<?php echo $rows['name']." <br>".nl2br($rows['detail']) ; ?>" id="m2"><?php echo $rows['name'] ; ?></a>
我是否可以使用Javascript/PHP运行/执行此链接,就像有人单击该链接一样?
Can I run/execute this link using Javascript/PHP as if someone clicked on this link?
推荐答案
使用javascript/jquery无法单击链接.您可以使用$('#m2').click()
触发绑定事件,但不会打开URL.您可以做的是,使用document.location.href打开页面
It is not possible to click on a link using javascript / jquery. You can trigger the bound events using $('#m2').click()
but it will not open the url. What you could do is, use document.location.href to open the page
document.location.href = document.getElementById('m2').href;
这篇关于使用javascript执行链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文