Change the URL of a link

Source: Internet
Author: User

Demand, a link PC is customer service, mobile is the phone number;

Idea 1: If a link is a page only one, write two sets. Do the show and hide it.

Idea 2: If a link has a lot of pages, is the promotion page, only a set of code to implement the PC and mobile, this method is now more appropriate.

Idea 3: If the fixed section. such as corporate websites, and mobile pages. It's better to separate the layout.

1 Get object, click. Determine the width of the PC's screen, and add a phone number less than 900.

Add a customer service link if it is greater than 900;

<script type= "Text/javascript" >
$ (". A_tel"). Click (function () {
var w = document.documentElement.scrollWidth | | Document.body.scrollWidth;
if (w<900) {
$ (this). attr ("href", "tel:400-9696-898");
}else{
$ (this). attr ("href", "http://www41.53kf.com/webCompany.php?kf_sign=jkzMDMTUzMExNjEwNTUwMzkzMzY1MDAy&arg= 10101905&style=1 ");
}

})

Judging Mobile and PC
if (Navigator.userAgent.match (/(phone|pad|pod|iphone|ipod|ios|ipad| android| mobile| blackberry| iemobile| mqqbrowser| juc| fennec|wosbrowser| Browserng| webos| symbian| Windows Phone))) {
Alert (' Mobile side ')
}else{
Alert (' PC side ')
}

</script>

Change the URL of a link

Related Article

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.