473,698 Members | 2,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I want to display the result of a javascript function within html underline tag.

5 New Member
Hi,
I am a beginner with javascript.Plea se help me clarify how to display the result of a javascript function within html underline tag.PFA the code.
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4.  
  5. <script type="text/javascript">
  6.  
  7. function whichBrs() {
  8. var agt=navigator.userAgent.toLowerCase();
  9. if (agt.indexOf("opera") != -1) return 'Opera';
  10. if (agt.indexOf("staroffice") != -1) return 'Star Office';
  11. if (agt.indexOf("webtv") != -1) return 'WebTV';
  12. if (agt.indexOf("beonex") != -1) return 'Beonex';
  13. if (agt.indexOf("chimera") != -1) return 'Chimera';
  14. if (agt.indexOf("netpositive") != -1) return 'NetPositive';
  15. if (agt.indexOf("phoenix") != -1) return 'Phoenix';
  16. if (agt.indexOf("firefox") != -1) return 'Firefox';
  17. if (agt.indexOf("safari") != -1) return 'Safari';
  18. if (agt.indexOf("skipstone") != -1) return 'SkipStone';
  19. if (agt.indexOf("msie") != -1) return 'Internet Explorer';
  20. if (agt.indexOf("netscape") != -1) return 'Netscape';
  21. if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
  22. if (agt.indexOf('\/') != -1) {
  23. if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
  24. return navigator.userAgent.substr(0,agt.indexOf('\/'));}
  25. else return 'Netscape';} else if (agt.indexOf(' ') != -1)
  26. return navigator.userAgent.substr(0,agt.indexOf(' '));
  27. else return navigator.userAgent;
  28. }
  29.  
  30.  
  31.  
  32. </script>
  33. </head>
  34.  
  35. <body>
  36. Your browser name is <u onload="whichBrs()"></u>
  37. </body>
  38.  
  39. </body>
  40. </html>
  41.  
  42.  
Attached Files
File Type: txt BrowserDetectJavaScriptCode.txt (1.2 KB, 494 views)
Apr 5 '11 #1
2 11651
Romulo NF
54 New Member
Greetings,

In fact there are lots of ways you can acomplish such thing, here are some examples:

Expand|Select|Wrap|Line Numbers
  1. Your browser name is <u><script type="text/javascript">document.write(whichBrs());</script></u>
  2.  
Or you can do something like:

Expand|Select|Wrap|Line Numbers
  1. Your browser name is <u id="yourBrowser"></u>
  2.  
  3. <script>
  4. var myVar = document.getElementById("yourBrowser"),
  5.     textNode = document.createTextNode(whichBrs());
  6.  
  7. myVar.appendChild(textNode);
  8. </script>
  9.  
Or even:

Expand|Select|Wrap|Line Numbers
  1. Your browser name is <u id="yourBrowser"></u>
  2.  
  3. <script>
  4. var myVar = document.getElementById("yourBrowser");
  5.  
  6. myVar.innerHTML = whichBrs();
  7. </script>
  8.  
Regards,
Romulo
Apr 5 '11 #2
LindaDhasan
5 New Member
Thanks romulo.

actually i already fixed the issue with third solution .Thanks for the additional information.
Apr 6 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1767
by: Markusek Peter | last post by:
How can I call JavaScript function within <TABLE> tags. I've got <table width="here should be return value from js script"> Thank you.
2
5999
by: hemant | last post by:
hi all, i am working on a website using asp.net-vb.net i am using a textbox(web control) and want to run javascript function as the text in the textbox is changed. but as soon as i run the page in the browser i get the foll. message: Compiler Error Message: BC30456: 'func' is not a member of 'ASP.frmMaster_aspx'. where func is name of the function
3
3110
by: MicroMoth | last post by:
Hi, I'm trying to call a Javascript function within a foreach loop. I am loop over a series of users and I want to call the JS function which opens a new window, passing in the user id to each call for the JS function. So far I've done this: foreach (USER _user in users) { string jscriptString = "<script language='JavaScript'>";
1
9883
by: supin | last post by:
hi, i work in asp.net2.0/c#.not much expert in javascript.i have a variable declared in the c# code behind page.assume the variable contains some value. i have a javascript function in the <script> </script> area of the html source view of the corresponding aspx(asp.net)page. my requirement is how do i access the variable which i mentioned above in the c# code behind page?i need to use the variable in the javascript function. ...
4
38649
by: sajithkahawatta | last post by:
i want to call a java script function from code behind. in page1.aspx page i placed script' <script language="javascript"> function SetSelected() { infoTextBox.select(); } </script>
10
2044
by: patelxxx | last post by:
Problem: I am trying to input my name in a text box and I click on transfer and I want the name to appear on the same page (i.e. in another form). How is this done? <BODY> <HTML> <form id="form1", action="testing.htm" method="post"> Your name: <input type="text" name="name"/> </form>
2
6634
by: gsherp | last post by:
Is there anyway to call a javascript function within an innerHTML call? example: var someelement = document.createElement("input"); var someelement2 = document.createElement("input"); function test(str) { var str2 = test.substring(0,4); return str2; }
5
10212
by: gubbachchi | last post by:
Hi all, How to pass the php date variable to javascript function. Here is the code I have tried out, but this is not recovering the date correctly in the javascript function <html> <script type="text/javascript"> function add($date1){ alert($date1)
7
1653
Daxthecon
by: Daxthecon | last post by:
What I need. -When there is nothing in the cell it needs to be red -When there is something in the cell it should be green -There should be a search input and it should bring up(on the next page after clicking search) the columns that apply to that search keyword only. All this needs to be done in html and javascript. I've created the frame turned the excel to a csv and then made frames so tht it will look presentable. If I have to I...
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8898
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.