2

I just need to someone to direct me in how I would take values from a javascript page and insert them into a html page in a table rather than have one chunk of values being fed back to me, cheers.

    Javascript:
document.write(''
     + 'Browser Name: ' + objbrowserName + '<br>'
     + 'Full Version: ' + objfullVersion + '<br>'
     + 'Major Version: ' + objbrowserName + " " + objBrMajorVersion + '<br>'
     + 'Navigator Name: ' + navigator.appName + '<br>'
     + 'Navigator UserAgent: ' + navigator.userAgent + '<br>'
     + 'Operating System: ' + OSName + '<br>'
     + 'Cookies Enabled: ' + Cookies + '<br>'
     + 'Java Enabled: ' + Java + '<br>'
     + 'Flash Player Version: ' + version + '<br>'
     + 'WebSockets Supported: ' + WebSocket + '<br>'
     + 'Browser Size: ' + BrowserW + " x " + BrowserH + '<br>'
     + 'Screen Size: ' + ScreenW + " x " + ScreenH + '<br>'
     + 'Colour Depth: ' + Depth + '<br>'
    )

This is what is returned:

  Browser Name: Chrome
Full Version: 41.0.2272.89
Major Version: Chrome 41
Navigator Name: Netscape
Navigator UserAgent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36
Operating System: Windows
Cookies Enabled: True
Java Enabled: True
Flash Player Version: 17,0,0
WebSockets Supported: True
Browser Size: 500 x 420
Screen Size: 1280 x 1024
Colour Depth: 24 bit

However I want to be able break up the data into a table with 2 columns but i'm confused as to how to get the data from the JS file.

2
  • Can you provide a basic jsbin with the data you're after? Commented Apr 30, 2015 at 10:56
  • @EdwardKnowles I amended the original post Commented Apr 30, 2015 at 11:09

1 Answer 1

8

Here is solution

Javascript

 <script>
 function get_value(){
  var BrowserName = objbrowserName;
  document.getElementById('mydiv').innerHTML = BrowserName;
 }
 </script>

Html

 <div id="mydiv"></div>
 <button type="button" onclick="get_value();">Get Value</button>
Sign up to request clarification or add additional context in comments.

2 Comments

I need it to appear on load, not as a button but thanks one step closer :)
@luke you simply use this window.onload = function(){ // your code goes here }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.