RegExp Navigator.userAgent

Jan 5, 2003

Why is /MSIE (5.5)|[6789]/.test(navigator.userAgent) true
when navigator.userAgent == "Opera/7.0 (Windows 2000; U) [en]" ?

View 3 Replies


ADVERTISEMENT

Navigator.userAgent

Jul 23, 2005

navigator.userAgent returns information about the user operting system,
Browser etc.

Usually you get somthing like:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
or
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET
CLR 1.1.4322)
or
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624
Netscape/7.1 (ax)

imho there is too many information, most of it confusing for the user. What
I would like to do is, evaluate the information and
reduce it to the opereting system and browser version.

e.g.

MSIE 6.0, Windows XP

or

Netscape 7.1, Windows 98


obstacles:
- As far as I know, the structure of the data returned by
navigator.userAgent depends on the browser.
So a specification for each browser would be a good starting point, any
ideas where to find?

- Why do I get "Windows NT 5.1" instead of "Windows XP"? Any other
synonyms?

I neither tested it on macs nor linux systems...

View 12 Replies View Related

Feature Detection To Replace Use Of "navigator.userAgent" In Yahoo! UI Event.js?

Sep 1, 2006

I'm picking apart the Yahoo! UI event.js library and stripping it down
to just what I need. I'm also trying to make the parts I use better.
I'm stumped on how to fix the code for the getPageX() method. This
method is supposed to give the same value in IE as other browsers for
the event position relative to the left of the page. This value will be
greater than the position relative to the left of the browser if the
browser is scrolled to the right. What would be the appropriate feature
detection to use for the conditional in the following line?

if ( this.isIE ) {

Thank you,
Peter


isSafari: (/Safari|Konqueror|KHTML/gi).test(navigator.userAgent),

isIE: (!this.isSafari && !navigator.userAgent.match(/opera/gi) &&
navigator.userAgent.match(/msie/gi)),


getPageX: function(ev) {
var x = ev.pageX;
if (!x && 0 !== x) {
x = ev.clientX || 0;

if ( this.isIE ) {
x += this._getScroll()[1];
}
}
return x;
},

_getScroll: function() {
var dd = document.documentElement, db = document.body;
if (dd && dd.scrollTop) {
return [dd.scrollTop, dd.scrollLeft];
} else if (db) {
return [db.scrollTop, db.scrollLeft];
}
return [0, 0];
}

View 10 Replies View Related

Diving Into Regexp By Porting A Perl Script Over To Js That Uses Regexp To Compress Into A Bookmarklet Capable Format?

Aug 10, 2010

I'm finally diving into regexp by porting a perl script over to js that uses regexp to compress javascript into a bookmarklet capable format.I've successfully worked out 90% of the expressions but am troubled with a few, this one at the moment is odd:I want to remove the first line if it hasjavascript:So I thought str.replace(/^javascripts+:s+/, "") would be ok. I want javascript text, any space, colon, any space and new line. what I'm doing wrong.btw this is the original perl version

$src =~ s{^// ?javascript.+:.+
}{};

View 3 Replies View Related

RegExp.input, RegExp.leftContext, ...

Jan 19, 2007

I found this in felgall's page. I added script tag

<script type="text/javascript">

var re = /(t)he/g;
var mystring = "Over the moon.";
re.text(mystring);
alert(RegExp.input); // or RegExp.$_
alert(RegExp.leftContext); // or RegExp["$`"]
alert(RegExp.rightContext); // or RegExp["$'"]
alert(RegExp.lastMatch); // or RegExp["$&"]
alert(RegExp.lastParen); // or RegExp["$+"]
alert(re.source);

</script>

I don't see message box. Please tell me what I can do.

View 3 Replies View Related

How To Check That Navigator Was Restarted

Sep 27, 2010

I need to know that navigator (IE or FF) was restarted or just know that cache was deleted.When I change sth in JS script, my old script is still in user navigator cache. I need user to use my new script, so he/she must clear cache or restart navigator (or maybe sth else). I show allert() that he/she mast do it, but how can I ckeck he/she did it?

View 1 Replies View Related

Navigator Object : How Do I Get All The Inside Elements?

Jul 23, 2005

I am trying to read all the navigator object elements

1. Using the navigator.length returns undefined, cant use for loop;

2.Using and array of known elements like
var a = Array("appCodeName","appName","appVersion");
I seem to miss something to get it combined like navigator.a[i]

View 13 Replies View Related

Valid Navigator.AppName Values

Sep 1, 2005

Where can I find a list of valid names for Navigator.AppName?

View 13 Replies View Related

BrowserName=navigator.appName Not Working?

Jun 16, 2009

I have this code and I don't understand why this isn't working.Head section:

<script>
function IEorMoz(){
// get browser resolution

[code]...

ps I know the 2 div's are the same, but this is only for testing.

View 40 Replies View Related

Navigator.javaEnabled Always Returns False In Mozilla/Opera

Jul 23, 2005

I am trying to test changes to my site (made only on my local machine so
far) in IE v6, Mozilla 1.6, and Opera 7.5.

When I test "navigator.javaEnabled in IE it corretly reports true/false
depending on whether javascript is enabled.

However, both Mozilla and Opera *always* return false. How can I properly
test to see if javascript is enabled/disabled in these two browsers? (If you
have a reference on the web, please point me to it as I've spent several
hours trying to find what I need.) Code:

View 1 Replies View Related

JQuery :: Custom Carousel Queuing When Change Between Navigator Tabs

Aug 15, 2011

I dedicated some time creating my own carousel with images, and got a little problem:

It works perfectly when I´m on the website, but when I change between the tabs on firefox/chrome, it seems that the function make some kind of queue, and when I come back to the website, it execute the function a lot of times at the same times, passing between the images in less than half second (I configured to change every 5 seconds).

function circCar (car) {

Here is the code, and if anybody wants to see the problem, open this url, open another tab (blank or another website) and stay on it about 15 seconds, when you come back to my site, you will see the queued function. [url]

View 2 Replies View Related

RegExp

Aug 30, 2005

I need to create a dynamically pattern match
for validate a number input, first without
decimals and then with 2 or more decimals.

View 9 Replies View Related

RegExp For Date

Jul 23, 2005

i have this function to check date (not mine)

function (s_date) {
// check format
if (!re_dt.test(s_date))
return false;
// check allowed ranges
if (RegExp.$1 > 31 || RegExp.$2 > 12)
return false;
// check number of day in month
var dt_test = new Date(RegExp.$3, Number(RegExp.$2-1), RegExp.$1);
if (dt_test.getMonth() != Number(RegExp.$2-1))
return false;
return true;}

it will check in this format DD-MM-YYYY
is it possible to modify it to be (MM/DD/YYYY OR DD/MM/YYYY) in one function?

View 3 Replies View Related

Regexp - Removing From URL

Dec 26, 2005

I am weak when it comes to regexp but hoped someone might know in this case.
I am trying to take a url like this :

something.lasso?blah=blah&blah2=blah2&sort=hello&blah3=blah3

And remove the &sort=XXX without hurting the rest of the url. The parameter
to be replaced would be a parameter passed to a function. Here is what I
have so far:

function refresh(item) {
current = document.location.href;
if(current.match(item.name+'='))
//pseudo code here
//current.replace(item.name regexp , '');

return (current + "&" + item.name + "=" + item.value);

This function would be fired like this :

All <input type="radio" name="show" value="all"
onclick="document.location=refresh(this);">
Mine <input type="radio" name="show" value="mine"
onclick="document.location=refresh(this);">

View 13 Replies View Related

RegExp FAQENTRY

Jul 20, 2005

An important question, probably not treated by many otherwise worthwhile
sources, must be on feature detection of the newer RegExp facilities -
for example, greedy/non-greedy.

The answer may be that it is not possible to do so in a safe manner;
that one can do no better than something like

document.write("Testing non-greedy :- ")
X = /<trialRegExp>/.test(string)
document.write("survived.")

That is, nevertheless, a useful answer; if it is right, it prevents the
naive seeking anything better, and if it is wrong someone will soon say
so.

Where a page requires an advanced RegExp facility, it is best to have a
controlled failure at a well-chosen point.

Putting something in the posted FAQ will provide an opportunity for
adding a reference to the Notes; and, without such a reference, their
value is much reduced.

View 5 Replies View Related

RegExp Problem

Sep 22, 2007

I have a script that checks if the value of the input is valid but I have a problem with it. This is my RegExp code:

if(obj.value.match(/!@#$\%^&*()+/g))
obj.value = "Use only legit characters";

It's supposed to check if the input value has invlaid code but it doesn't seem to work.

Also I'd like to, instead of just writing the error message, to be able to change the input value to a valid one(IE: Peo$p@le@ To People)

I think it can be done with the replace statement like this:

obj.value.replace(/!@#$\%^&*()+/g,"")

So whenever it finds that invalid char it just writes nothing instead of it.

View 4 Replies View Related

Can't Use Regexp Variable Twice

Jul 17, 2006

I have found that I can't use a regexp variable twice. For instance, if I have the following code then the first will evaluate true and the second one false, despite the fact that they should both evaluate true:

reg = RegExp('[AF]PO', 'gi');

if (reg.test(document.getElementById('address_line_1').value) && reg.test(document.getElementById('address_line_2').value))
alert('You entered an APO or FPO address!');

To get the code above to work I have to do the following:

reg = RegExp('[AF]PO', 'gi');
reg2 = RegExp('[AF]PO', 'gi');

if (reg.test(document.getElementById('address_line_1').value) && reg2.test(document.getElementById('address_line_2').value))
alert('You entered an APO or FPO address!');

Why is it I have to have two regexp variables created? Is the variable "one use" or am I doing something wrong here?

View 2 Replies View Related

Regexp / What Does This Match?

Jul 1, 2010

Can someone please let me know what this matches - i can work out some but not all code...

View 3 Replies View Related

Simple Regexp

Apr 18, 2005

im tired of working all day...
please how to delete the value with regexp...
i tried this

bla.replace('value="/.+/"', '');

it wont work...

View 5 Replies View Related

Email Regexp

Mar 10, 2006

I am trying to find an email regexp but none seem to validate the following example:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@xx....xxx.xxxxxx.xx

could I have one which also validate this sort ....

View 6 Replies View Related

Regexp Replace

Jul 13, 2007

I want to replace a string after checking it is valid by passing the values to a function.

The string is '<img width="300" height="300">'

Code:
var text = '<img width=300 height=300>'
text = text.replace(/<img width=(.*?) height=(.*?)>/gi, check_img($1, $2));
The $1 and $2 values are not being passed to the function.
This same method works in PHP by the e Modifier but not in JS.

View 2 Replies View Related

RegExp To Alter An Element Name?

Jul 23, 2005

Given a string like:

<input type="button" name="b1" value="Button">

I want to locate the element's name (b1) and replace it with this very name
+ some spice.

And of course it can be any kind of loose HTML syntacs:

name="b1"
NAME="b1"
name='b1'
NAME=b1
....

So it's something like (totally wrong expression, I know):

/name=(s+|'|")(name)/$1+my_spice/i

But I did not work with regexp for a longest time, and I'm just too lazy (sorry to admit) to read manuals over again just for one case.

View 7 Replies View Related

RegExp: Backreference In ClassRange

Jul 23, 2005

Consider the following RegExp:

/[1]/


ECMA-262 says:

<quote (with slight modification of non-ASCII character)>

15.10.2.11 DecimalEscape

The production DecimalEscape :: DecimalIntegerLiteral [lookahead != DecimalDigit] evaluates as follows.

1. Let i be the MV of DecimalIntegerLiteral.
2. If i is zero, return the EscapeValue consisting of a <NUL> character (Unicode value 0000).
3. Return the EscapeValue consisting of the integer i.

...

View 1 Replies View Related

Validate EMail With RegExp...

Nov 3, 2005

My understanding of regular expressions is rudimentary, at best.

I have this RegExp to to a very simple validation of an email-address, but it turns out that it refuses to accept mail-addresses with hypens in them.

Can anybody please help me adjust it so it will accept addresses like dag-sunde@test-domain.net too?

Here's what got:

function validateEmail(eMail) {
return /^(w+.)*(w+)@(w+.)+([a-zA-Z]{2,4})$/.test(eMail);
}

View 12 Replies View Related

RegExp Array Problem

Dec 15, 2005

I'm trying to write a RegExp that will return search an array and
return the closest 10 matches, for example, if i entered "Hel" and my
array contained "Hello", "Hell", it would return Hello and Hell,
however, if i entered "ell" it wouldn't return anything.

The code that i need to modify is: -

var searchterm = "Hel";
var re = new RegExp("^")
re = /^/

if(searchterm !='')
{
var matches = 0;
for(var i=0; i<myarray.length; i++)
{
if(searchme != false)
{
if (searchterm == myarray[i])
{
write (myarray[i]);
matches++;
}

}
if(matches==10) break
}
}

Obviously this is only returning exact matches and having tried to add
the RegExp into there hasn't worked as yet.

View 7 Replies View Related

Trying To Match A Newline With A Regexp.

Aug 6, 2009

Trying to match a string containing a newline, among other things.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved