JavaScript Custom function to determine whether the Web site access type is PC or mobile terminal _javascript tips

Source: Internet
Author: User
Because many mobile terminals do not support Flash, many colorful flash effects do not come out. If you can determine the type of access to a Web page (PC or mobile terminal). Can be the right remedy, find the solution!

The type of access is mobile terminal we use. gif instead of flash (. swf suffix) animation, the PC side does not make changes. This is more perfect!

As shown below, the function Flashchecker () is the type used to detect access.
Copy Code code as follows:

<script language= "javascript" type= "Text/javascript" >
/*
* To detect whether it is a PC or a mobile terminal
* Return: Flashchecker (). F = = True PC Terminal
* Instead of mobile terminals
*/
function Flashchecker () {
var hasflash = 0;
var flashversion = 0;
var Isie =/* @cc_on!@*/0;
if (Isie) {
var swf = new ActiveXObject ("Shockwaveflash.shockwaveflash");
if (SWF) {
Hasflash = 1;
vswf = swf. GetVariable ("$version");
Flashversion = parseint (Vswf.split ("") [1].split (",") [0]);
}
}
else {
if (navigator.plugins && navigator.plugins.length > 0) {
var swf = navigator.plugins["Shockwave Flash"];
if (SWF) {
Hasflash = 1;
var words = Swf.description.split ("");
for (var i = 0; i < words.length; ++i) {
if (isNaN (parseint (words[i))) {
Continue
}
Flashversion = parseint (Words[i]);
}
}
}
}
return {
F:hasflash, V:flashversion
};
}
</script>

Expand:
Copy Code code as follows:

<script language= "javascript" type= "Text/javascript" >
/*
* Output SWF animation based on parameters
* URL: Click the jump address after the SWF animation
* Swflink: *.swf material Address
*/
function getswfhtml (URL, swflink) {
html = "<a style= ' Position:absolute;" top:0; left:0; bottom:0; right:0; Display:block; " +
"width:100%; Height:expression (This.parentNode.scrollHeight); Filter:alpha (opacity=0); "+
"OPACITY:0; Background: #FFF; ' href= ' "+ URL +" ' target= ' _blank ' > ' +
"</a>" +
"<object width= ' 590 ' height= ' align= ' middle ' >" +
"<param name= ' allowscriptaccess ' value= ' Never '/> '" +
"<param name= ' quality ' value= ' high '/>" +
"<param name= ' wmode ' value= ' Transparent '/> '" +
"<param name= ' movie ' value= '" + swflink+ "'/>" +
"<embed wmode= ' Transparent ' src= '" + swflink+ "' quality= ' high '" +
"Width= ' 590 ' height= ' align= ' Middle ' allowscriptaccess= ' Never ' type= '" Application/x-shockwave-flash ' "+
"pluginspage= '" + url + "'/>" +
"</object>";


return HTML;
}
</script>
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.