添加一个 onclick 函数以转到 JavaScript 中的 url? [英] Adding an onclick function to go to url in JavaScript?
本文介绍了添加一个 onclick 函数以转到 JavaScript 中的 url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户将鼠标悬停在一个字段上时,我正在使用这个漂亮的小 JavaScript 来突出显示该字段.你能告诉我是否有一种方法可以添加一个 onclick
函数,它将充当一个链接并转到一个 URL?
I am using this fancy little JavaScript to highlight a field as the user hovers over it. Could you please tell me if there is a way of adding an onclick
function which will act as a link and go to a URL?
<script>
$(function() {
$('tr').hover(function() {
$(this).css('background-color', '#eee');
$(this).contents('td').css({'border': '0px solid red', 'border-left': 'none', 'border-right': 'none'});
$(this).contents('td:first').css('border-left', '0px solid red');
$(this).contents('td:last').css('border-right', '0px solid red');
},
function() {
$(this).css('background-color', '#FFFFFF');
$(this).contents('td').css('border', 'none');
$('a#read_message.php').click(function(){ URL(); });
});
});
</script>
推荐答案
尝试
window.location = url;
也用
window.open(url);
如果您想在新窗口中打开.
if you want to open in a new window.
这篇关于添加一个 onclick 函数以转到 JavaScript 中的 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文