Jump to content

khushboo.singh

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by khushboo.singh

  1. Got out puting.

    In html file put <script src="array.json"></script> in body tag instead of head tag. Then it will work you try it.

     

    Thanks everyone

  2. How to add .json file in html document.

     

    I tried like this ,but not got output

     

    array.json file

     

    var employees = [
    {
    "firstName":"John",
    "lastName":"Doe"
    },
    {
    "firstName":"Anna",
    "lastName":"Smith"
    },
    {
    "firstName":"Peter",
    "lastName":"Jones"
    },
    ];
    employees[0].firstName="Gilbert";
    document.getElementById("demo").innerHTML =
    employees[0].firstName + " " + employees[0].lastName;
    abc.html file
    <!DOCTYPE html>
    <html>
    <head>
    <script src="array.json"></script>
    </head>
    <body>
    <h2>Create a JavaScript Object</h2>
    <p id="demo"></p>
    </body>
    </html>

     

  3. how to change the content of div tag by another html file externally using javascriptin my HTML file i want to cange content of div tag "hello freinds" with another file content i.e image.html without opening new tab<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Amazon</title><link rel="stylesheet" href="amazon.css" /> </head><body> <a href="http://www.microsoft.com" id="one" onMouseOver="return submenu('first','inline');" onMouseOut="return submenu('first','none');">Menu 1</a><br /> <a href="http://www.vnnotech.com" onMouseOver="return submenu('second','inline');" onMouseOut="return submenu('second','none');">Menu 2</a><br /> <a href="#" onclick="hi('third');" >Menu3</a> <div id="first"> This is first div </div> <div id="second"> This is second div </div> <div id="third"> hello friends </div><script>function submenu(item, visibility) {document.getElementById(item).style.display = visibility;return false;}function hi(item1){var newContent="http://localhost/project/image.html";document.getElementById(item1).innerHTML="image.html";return false;}</script></body></html>

×
×
  • Create New...