Firefox does not support the disabled attribute solution-based on jquery.

Source: Internet
Author: User

The project encountered a headache. The setting of <A> Disabled = "disabled" in Firefox is invalid. What should we do? We can only turn to powerful Js.

The idea is as follows:

To invalidate <A>, you must consider the following aspects: 1. block default behavior ---- hyperlink; 2. stop its mouse events. The Code uses onclick as an example. jquery is also used in the Code. Who calls it so easy to use.

<% @ Page Language = "Java" contenttype = "text/html; charset = UTF-8" <br/> pageencoding = "UTF-8" %> <br/> <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/TR/html4/loose.dtd"> <br/> <HTML> <br/> <pead> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "> <br/> <title> insert title here </title> <br/> <MCE: script Type = "text/JavaScript" src = "JS/jquery. JS "mce_src =" JS/jquery. JS "> </MCE: SCRIPT> <br/> </pead> <br/> <MCE: Script Type =" text/JavaScript "> <! -- <Br/> $ (function () {<br/> $ ("A [disabled]"). addclass ("Disable"); // Add a new class. Note that the original class of the label is not overwritten. <br/>}); <br/> function clickevent (oevent) {<br/> var oevent = oevent? Oevent: window. event; <br/> oevent. preventdefault (); // prevents hyperlinks <br/> var tar; <br/> If (navigator. appname = "Microsoft Internet Explorer") {<br/> tar = oevent. srcelement; <br/>}else {<br/> tarw.oevent.tar get; <br/>}< br/> If (TAR. getattribute ("disabled") {<br/> return false; // stop click events <br/>}< br/> alert ("Who says I'm useless !? "); <Br/>}; <br/> function clickevent1 (oevent) {<br/> alert (" Who says I'm useless !? "); <Br/>}; <br/> // --> </MCE: SCRIPT> <br/> <MCE: style> <! -- <Br/>. disable {<br/> color: Gray; // simulated disabled with Gray effect <br/>}< br/> --> </MCE: style> <style mce_bogus = "1">. disable {<br/> color: Gray; // simulate disabled to gray <br/>}</style> <br/> <body> <br/> <p> <a href = "http://baidu.com" mce_href =" http://baidu.com "Disabled =" disabled "Title =" this is the default prompt 1. "onclick =" clickevent1 (event ); "> I should be useless </a> </P> <br/> <p> <a href =" http://baidu.com "mce_href =" http://baidu.com "Disabled =" disabled "title = "this is the default prompt 1. "onclick =" clickevent (event); "> I am useless now </a> </P> <br/> </body> <br/> </ptml>

 

 

How about it? Try it! Ga ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.