By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,583 Members | 3,480 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,583 IT Pros & Developers. It's quick & easy.

partitioning the program depending upon browser

P: n/a
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.

Apr 19 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Apr 19, 2:45 pm, rajasekhar <rajaja...@gmail.comwrote:
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

Apr 19 '07 #2

P: n/a
On Apr 19, 4:21 pm, Darko <darko.maksimo...@gmail.comwrote:
On Apr 19, 2:45 pm, rajasekhar <rajaja...@gmail.comwrote:
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

Apr 19 '07 #3

P: n/a
Darko said the following on 4/19/2007 10:21 AM:
On Apr 19, 2:45 pm, rajasekhar <rajaja...@gmail.comwrote:
>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"
And then discover why the User Agent string is 100% unreliable?
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.
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/>

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.

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>";
I think if I were going to use that scenario, my first string to test
for would be the word "Opera" instead of any other browser.

But, just to satisfy my curiosity, what code would you give to a UA
where the UserAgent string contains this, and only this, string:

"My F**king Browser"

The asterisks are there because this is a family oriented group but I
think you can guess what they should be. Would you tell me that your
page wouldn't work in the browser simply because you can't determine,
based on a bogus string, what code to give me?

<URL: http://jibbering.com/faq/index.html#FAQ4_26>

More interesting reading.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 19 '07 #4

P: n/a
"Randy Webb" <Hi************@aol.comwrote in message
news:46********************@giganews.com...
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
Apr 21 '07 #5

P: n/a
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

Apr 21 '07 #6

P: n/a
-Lost said the following on 4/20/2007 8:05 PM:
"Randy Webb" <Hi************@aol.comwrote in message
news:46********************@giganews.com...
>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.
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.
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.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 21 '07 #7

P: n/a
Peter Michaux said the following on 4/20/2007 8:10 PM:
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?
They are still on my to-do list that seems to be never ending. The issue
with it now of not loading from the AOL server on a change source click
has moved it up in the stack though.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 21 '07 #8

P: n/a
"Randy Webb" <Hi************@aol.comwrote in message
news:D8********************@giganews.com...
-Lost said the following on 4/20/2007 8:05 PM:
>"Randy Webb" <Hi************@aol.comwrote in message
news:46********************@giganews.com...
>>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
Apr 21 '07 #9

P: n/a
-Lost said the following on 4/21/2007 1:47 AM:
"Randy Webb" <Hi************@aol.comwrote in message
news:D8********************@giganews.com...
>-Lost said the following on 4/20/2007 8:05 PM:
>>"Randy Webb" <Hi************@aol.comwrote in message
news:46********************@giganews.com...

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...
I did that originally to allow the Notes to be visible and the page was
getting sufficiently long enough that I didn't like the way it looked.
Maybe I need to go back to the non-overflow version.
>>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.
The innerHTML button inserts a script block into a div element and
attempts to load a .js file. If it works, you get an alert. That is all
it is testing, not a support for innerHTML itself. I wouldn't expect a
browser in the future to support it unless something comes about where
enough people start complaining about ajax apps with script blocks in
them not getting executed causes the browser people to make it start
executing scripts inserted via innerHTML. That column is left there more
for historical reasons than anything. Mostly historical in the sense
that I wasted so much of my time compiling that data on it that I don't
want to delete it :)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 21 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.