Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
145 views
in Technique[技术] by (71.8m points)

javascript - 在JavaScript中添加onclick函数转到url?(Adding an onclick function to go to url in JavaScript?)

I am using this fancy little JavaScript to highlight a field as the user hovers over it.(我正在使用这个花哨的小JavaScript来突出显示用户在其上悬停的字段。)

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?(你有没有可以告诉我是否有一种方法可以添加一个onclick函数,它将作为一个链接并转到一个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>   ask by John Taylor translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try(尝试)

window.location = url; Also use(也用) window.open(url); if you want to open in a new window.(如果你想在新窗口中打开。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...