PDA

View Full Version : سوال: درخواست اسکریپت هشدار برای اینترنت اکسپلورر



soroush.r70
جمعه 30 دی 1390, 14:19 عصر
دوستان من یه اسکرپتی می خوام که وقتی کاربری با اینترنت اکسپلورر 6-7-8 وارد سایت می شه یه پیغام خطا بهش بده و داخل اون یه توضیحات داده بشه در مورد این مرورگر

djsaeedkhan
جمعه 30 دی 1390, 14:59 عصر
سلام
دوست عزیز اگر یه جستجو تو گوگل بزیند همیشه بهترین جواب رو پیدا می کنید

djsaeedkhan
جمعه 30 دی 1390, 15:01 عصر
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return parseFloat(dataString.substring(index+this.version SearchString.length+1));
},
dataBrowser: [
{
string: navigator.userAgent,
subString: "Chrome",
identity: "Chrome"
},
{ string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari",
versionSearch: "Version"
},
{
prop: window.opera,
identity: "Opera",
versionSearch: "Version"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{ // for newer Netscapes (6+)
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{ // for older Netscapes (4-)
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS : [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.userAgent,
subString: "iPhone",
identity: "iPhone/iPod"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
]

};
BrowserDetect.init();

djsaeedkhan
جمعه 30 دی 1390, 15:02 عصر
function getInternetExplorerVersion()
// Returns the version of Windows Internet Explorer or a -1
// (indicating the use of another browser).
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
function checkIEVersion()
{
var msg = "You're not using Windows Internet Explorer.";
var ver = getInternetExplorerVersion();
if ( ver> -1 )
{
if ( ver>= 8.0 )
msg = "You're using Windows Internet Explorer 8.";
else if ( ver == 7.0 )
msg = "You're using Windows Internet Explorer 7.";
else if ( ver == 6.0 )
msg = "You're using Windows Internet Explorer 6.";
else
msg = "You should upgrade your copy of Windows Internet Explorer";
}
alert( msg );
}

tux-world
شنبه 01 بهمن 1390, 00:24 صبح
از این کلاس خوب و کامل استفاده کن

pooryaarab
سه شنبه 02 آبان 1391, 12:11 عصر
چطوری میشه ازین اسکریپت استفاده کرد؟
کاربردشو مثال میزنید؟