Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > partitioning the program depending upon browser

Reply
Thread Tools

partitioning the program depending upon browser

 
 
rajasekhar
Guest
Posts: n/a
 
      04-19-2007
Hallo,

I am developing a site, and here whats the problem is: how to
partition the code, i.e. if I developed 1000 lines of code, in that I
want to show first 200 lines only if the user opens my website using
IE, and next 200 lines in Firefox, and remaining lines in another
browsers.

Here am asking that how to compatible the total code depending upon
the browsers used by users.

if you know any thing please mail me to rajaja...@gmail.com

thanking you,

Best Regards,
Rajasekhar.

 
Reply With Quote
 
 
 
 
Darko
Guest
Posts: n/a
 
      04-19-2007
On Apr 19, 2:45 pm, rajasekhar <rajaja...@gmail.com> wrote:
> Hallo,
>
> I am developing a site, and here whats the problem is: how to
> partition the code, i.e. if I developed 1000 lines of code, in that I
> want to show first 200 lines only if the user opens my website using
> IE, and next 200 lines in Firefox, and remaining lines in another
> browsers.
>
> Here am asking that how to compatible the total code depending upon
> the browsers used by users.
>
> if you know any thing please mail me to rajaja...@gmail.com
>
> thanking you,
>
> Best Regards,
> Rajasekhar.


If you are using PHP, you can investigate the _SERVER superglobal
variable, specifically its "HTTP_USER_AGENT" element, which for
example could be something like:
$_SERVER["[HTTP_USER_AGENT"] = "Mozilla/5.0 (X11; U; Linux i686
(x86_64); en-US; rv:1.8.1.1) Gecko/20061208 Firefox/2.0.0.1"

ASP.NET probably has its own ways of doing this. The point is, you
have to generate your code, cause from JS itself, I'm not sure you can
easily load js files and contents of your choice. From PHP, however,
you could, based on the value of $_SERVER["HTTP_USER_AGENT"], do
something like:
if ( strstr( $_SERVER["HTTP_USER_AGENT"], "Firefox" ) !== false )
echo "<script type='text/javascript' src='first.js'></
script>";
else if ( ... )
echo "<script type='text/javascript' src='second.js'></
script>";
etc.

Cheers

 
Reply With Quote
 
 
 
 
rajasekhar
Guest
Posts: n/a
 
      04-19-2007
On Apr 19, 4:21 pm, Darko <darko.maksimo...@gmail.com> wrote:
> On Apr 19, 2:45 pm, rajasekhar <rajaja...@gmail.com> wrote:
>
>
>
> > Hallo,

>
> > I am developing a site, and here whats the problem is: how to
> > partition the code, i.e. if I developed 1000 lines of code, in that I
> > want to show first 200 lines only if the user opens my website using
> > IE, and next 200 lines in Firefox, and remaining lines in another
> > browsers.

>
> > Here am asking that how to compatible the total code depending upon
> > the browsers used by users.

>
> > if you know any thing please mail me to rajaja...@gmail.com

>
> > thanking you,

>
> > Best Regards,
> > Rajasekhar.

>
> If you are using PHP, you can investigate the _SERVER superglobal
> variable, specifically its "HTTP_USER_AGENT" element, which for
> example could be something like:
> $_SERVER["[HTTP_USER_AGENT"] = "Mozilla/5.0 (X11; U; Linux i686
> (x86_64); en-US; rv:1.8.1.1) Gecko/20061208 Firefox/2.0.0.1"
>
> ASP.NET probably has its own ways of doing this. The point is, you
> have to generate your code, cause from JS itself, I'm not sure you can
> easily load js files and contents of your choice. From PHP, however,
> you could, based on the value of $_SERVER["HTTP_USER_AGENT"], do
> something like:
> if ( strstr( $_SERVER["HTTP_USER_AGENT"], "Firefox" ) !== false )
> echo "<script type='text/javascript' src='first.js'></
> script>";
> else if ( ... )
> echo "<script type='text/javascript' src='second.js'></
> script>";
> etc.
>
> Cheers

thank you, and its working.


urs,
rajasekhar

 
Reply With Quote
 
-Lost
Guest
Posts: n/a
 
      04-21-2007
"Randy Webb" <> wrote in message
news:...

> To date, the only browser that I know of that I can not dynamically load a .js file is
> iCab, and NS6. Since you appear to be using Linux based software, perhaps you could
> check the buttons on this page for me:
>
> <URL: http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/>
>
> You should get an initial alert and then clicking on a button at the top should give you
> a new alert if the browser supports that method.


I was unsure of something, does your Mozilla test include all related products? As in,
since it did not support "Change Source" or "Change InnerHTML", then Firefox probably
won't either?

(I did test with Firefox 1.5.0.11. I thought at least the innerHTML example would work.)

Also, "Change Source" in Internet Explorer 6.0.2900.2180.spsp_sp2_gdr.050301-1519 (XP SP2)
appears to load the file (I can see it downloading) but I never get an alert.

-Lost


 
Reply With Quote
 
Peter Michaux
Guest
Posts: n/a
 
      04-21-2007
Hi Randy,

> It is quite trivial actually. Search the archives for loadJSFile along
> with my name. Might be some interesting reading in there somewhere.
> There is also a long thread entitled "createTextNode and IE" that is
> interesting reading.
>
> To date, the only browser that I know of that I can not dynamically load
> a .js file is iCab, and NS6. Since you appear to be using Linux based
> software, perhaps you could check the buttons on this page for me:
>
> <URL:http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/>


Have you done any more investigation in this about sequential file
loading or the other smaller details we talked about?

Thanks,
Peter

 
Reply With Quote
 
-Lost
Guest
Posts: n/a
 
      04-21-2007
"Randy Webb" <> wrote in message
news...
> -Lost said the following on 4/20/2007 8:05 PM:
>> "Randy Webb" <> wrote in message
>> news:...
>>
>>> To date, the only browser that I know of that I can not dynamically load a .js file is
>>> iCab, and NS6. Since you appear to be using Linux based software, perhaps you could
>>> check the buttons on this page for me:
>>>
>>> <URL: http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/>
>>>
>>> You should get an initial alert and then clicking on a button at the top should give
>>> you a new alert if the browser supports that method.

>>
>> I was unsure of something, does your Mozilla test include all related products?

>
> No. That is why it also contains an entry for Firefox2.0 on WinXP. The Linux and MAC
> testing were done by others so I assume it was Mozilla proper and not a derivative as
> there are some derivatives listed seperately.


There is an entry for Firefox? I do not see it... oh wait...

You made it an overflow! I just now realized there is something beyond Mozilla 1.5 on Win
ME. Hehe...

>> As in, since it did not support "Change Source" or "Change InnerHTML", then Firefox
>> probably won't either?

>
> I doubt it as Changing Source is an IE proprietary thing by accessing it via an ID
> attribute of the Script element. The innerHTML test won't work in Firefox either.
>
>> (I did test with Firefox 1.5.0.11. I thought at least the innerHTML example would
>> work.)

>
> On what OS? I have it on XP and some results for Mac OSX.


XP SP2. I must be missing something. For example:

document.getElementsByTagName('p')[0].innerHTML = 'Woof!';

....works just fine in Firefox 1.5.0.11. I guess more specifically though:

first_p = document.getElementsByTagName('p')[0];
first_p.innerHTML = '<script src="innerHTML.js" type="text\/javascript"><\/script>';

Whilst the first P does have the updated innerHTML, it does not allow access to that
script's contents. Bummer.

OK, maybe I am not missing anything. Heh.

>> Also, "Change Source" in Internet Explorer 6.0.2900.2180.spsp_sp2_gdr.050301-1519 (XP
>> SP2) appears to load the file (I can see it downloading) but I never get an alert.

>
> I am going to have to check into that one. IE7 doesn't work from the on-line version so
> I will have to figure out why as when I tested it (I did the IE7 testing) it worked at
> the time for me to have put it on there as working. And just now re-testing it works
> offline so it is either something to do with the offline/on-line or the AOL server
> screwing it up.


-Lost


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
url fetching from xml depending upon selection shanti bhushan Python 8 05-18-2010 08:26 AM
wanna make object invisible/visible depending upon the click of radio button in asp 3.0 meet_ravipatel@yahoo.com Javascript 1 04-10-2007 05:04 PM
Calling function depending upon MACRO value param C++ 3 02-23-2006 09:59 AM
refreshing a sibling (?) frame works depending on the browser jazzdman@gmail.com Javascript 0 04-30-2005 04:30 AM
Program namespaces partitioning and new/delete operators GianGuz C++ 4 12-20-2004 03:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57