頁面被css內嵌javascript搞死了

來源:互聯網
上載者:User
自己寫了一個css內嵌javascript運算式,本打算讓單行文本輸入框屏蔽斷行符號提交的,結果開啟一個有眾多submit的列表,頁面開啟就無法響應了。查了半天,原來是自己寫的運算式惹的禍,去掉就有反映迅速了:

input{ readonly:expression((this.type=="text" && this.onkeydown==null)? (this.onkeydown=function(){if(event.keyCode==13)event.returnValue=false}) : "" );} 

看來css運算式雖可偷懶,但是對於表單對象眾多的頁面還是濫用不得。嘗試其它的解決辦法,例如與class綁定什麼的,會不會好些。自己沒試,先把這個問題記下。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.