开发者

a simple mailto: also fires postback on .net. How to prevent the postback?

开发者 https://www.devze.com 2023-03-06 20:23 出处:网络
I\'ve got a simple link <ahref=\"mailto:test@email.com\">test@email.com</a> Problem is in an asp.net page when using Internet Explorer 8 clicking on the link not only opens the email cl

I've got a simple link

    <a   href="mailto:test@email.com">test@email.com</a>

Problem is in an asp.net page when using Internet Explorer 8 clicking on the link not only opens the email client but also navigates the url to mailto:test@email.com i've tried adding onclick="return false;" however this prevents the mailto: from firing at all. so nothing happens in this case.

i think the problem comes from a scriptmanager on the same开发者_Go百科 page (which i kindof need)

again this only happens with IE. I havn't tested with previous versions of IE . But opera, ff, and chrome work just fine

just a quick edit. if i'm uisng a simple html page with IE8. it works just fine

Any ideas how to fix this?


It is firing postback because it is in Anchor so when you click on it try to find href link. You can use javascript or jquery to solve this problem.

<script type="text/javascript" src="jquery-1.4.1.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
                $('a').attr('href', '#');
            });
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消