添加onclick函数以转到JavaScript中的url? [英] Adding an onclick function to go to url in JavaScript?

查看:102
本文介绍了添加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屋!

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