<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body> <a href="http://www.baidu.com">百度</a> <a href="http://www.qq.com" onclick = "return f1()">腾讯</a> <a href="http://www.qq.com" onclick="javascript:return confirm('确认要删除吗?')">删除</a> <form action="http://www.taobao.com" method="post" >
用户名: <input type="text" name="uesrname" />
<input type="submit" value="提交" />
</form> <script type="text/javascript">
function f1(){
console.log('not');
return false;
}
var a = document.getElementsByTagName('a')[0];
a.onclick = function(){
console.log('NOT---A');
return false;
} var forms = document.getElementsByTagName('form')[0];
/* W3C浏览器下的 */
/*
forms.addEventListener('submit',function(evt){
console.log('not----form');
evt.preventDefault();
});
*/
/* IE浏览器下的 */
forms.attachEvent('onsubmit',function(){
console.log( '表单提交了' );
window.event.returnValue = false;
}) </script>
</body>
</html>

夺命雷公狗---在js里阻止a标签的跳转和form表单的跳转的更多相关文章

  1. Js document.frmLogin.action = '/login.htm';的意义和form表单的target属性

    一.解答:就是把 这个id名为frmLogin的form的提交地址改为上面的/login.htm <form id="frmLogin" name="frmLogi ...

  2. 参数传递的四种形式----- URL,超链接,js,form表单

    什么时候用GET,  查,删, 什么时候用POST,增,改  (特列:登陆用Post,因为不能让用户名和密码显示在URL上) 4种get传参方式 <html xmlns="http:/ ...

  3. ***四种参数传递的形式——URL,超链接,js,form表单

    什么时候用GET,  查,删 什么时候用POST,增,改  (特列:登陆用Post,因为不能让用户名和密码显示在URL上) 4种get传参方式 <html xmlns="http:// ...

  4. 夺命雷公狗---微信开发59----在线点播电影网1之ckplayer播放器

    我们节课程就要开始写一个小项目了,这项目主要是写一个在线点播电影影网的,我们用到的播放器是ckplayer ckplayer基本介绍: ckplayer的全称是:超酷flv播放器,他是一款用于网页上播 ...

  5. 夺命雷公狗-----React---12--添加类和样式

    <!DOCTYPE> <html> <head> <meta charset="utf-8"> <title></ ...

  6. 夺命雷公狗-----React---11--添加css样式的方法

    <!DOCTYPE> <html> <head> <meta charset="utf-8"> <title></ ...

  7. 夺命雷公狗-----React---10--组建嵌套进行数据遍历

    先写一个组建... 然后进行嵌套.. <!DOCTYPE html> <html lang="en"> <head> <meta char ...

  8. 夺命雷公狗-----React---9--map数据的遍历

    比如我们要实现的是这种效果: 用这种方法来写,她只能写死在哪,没啥意思,所以我们定义一个数据,然后来测试下map方法对她遍历出来的数据 <!DOCTYPE html> <html l ...

  9. 夺命雷公狗-----React---8--react官方提供的组建实现双向绑定

    首先要引入她.. <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

随机推荐

  1. HTML5样式和列表、CSS链接的四种状态

    一.HTML5样式 1.标签: <style>:样式定义: <link>:资源引用: 2.属性: type="text/css":引入文档类型: rel=& ...

  2. 我的第一个WCF程序,很简单适合我等菜鸟

    1.首先我罗列一下网站搜索并经过自己理解的WCF的含义: 1)WCF:(WIndows Communication Foundation)是由微软是由微软发展的一组数据通信的应用开发接口,可以翻译为W ...

  3. Class.getResourceAsStream() VS. ClassLoader.getResourceAsStream()

    For Class.getResourceAsStream(String name), if the name parameter doesn't start with a "/" ...

  4. SendEmail语法

    SendEmail语法 示例: /usr/local/bin/sendEmail -f shengwei.tang@joy4you.com -t @qq.com -s smtp.exmail.qq.c ...

  5. UR fall detection dataset

    http://fenix.univ.rzeszow.pl/~mkepski/ds/uf.html

  6. 30天,O2O速成攻略【8.22北京站】

    活动概况 时间:2015年8月22日13:30-16:30 地点:车库咖啡(北京市海淀西大街48号鑫鼎宾馆二层) 主办:APICloud.融云.品读者 网址:www.apicloud.com 费用:免 ...

  7. iOS小技巧

    键盘透明: textField.keyboardAppearance = UIKeyboardAppearanceAlert; 状态栏的网络活动风火轮是否旋转: [UIApplication shar ...

  8. Java 收集的代码 transient

    public class Main { public static void main(String[] args) { ((NULL)null).haha(); } } class NULL { p ...

  9. App上架审核指南翻译

    App Store Review Guidelines APP审核指南:https://developer.apple.com/app-store/review/guidelines/ 本文是自主翻译 ...

  10. checkbox判断选中

    $("input[type='checkbox']").is(':checked')