Results 1 to 8 of 8

Thread: How Can I Load De Content Of A Website Using JS. Please I Dont't Want To Use Frame.

  1. #1
    Join Date
    Nov 2016
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How Can I Load De Content Of A Website Using JS. Please I Dont't Want To Use Frame.

    I am tryin to include another webpage content to my webpage by this code, but it not working.
    Code:
    <!Doctype html>
    <html>
    <head>
    <script>
    function include(destination) {
    var e=window.document.createElement('script'); e.setAttribute('src',desti nation);
    window.document.body.appendChild(e);
    }</script>
    </head>
    <body onLoad="include('http://mywapsite.com');">
    </body>
    </html>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You can't exactly include "content" in this manner, you can include a script though. If the content at mywapsite is a script, it will work, but your syntax has an error and even if it were correct would do nothing more, perhaps even less than just using a script tag would do:

    Code:
    <script src="http://mywapsite.com">
    And it would really depend upon what's in the script, as to whether or not it would show any content or do anything.

    As for actually including one web site into another, browsers generally block that. Iframe is a possibility, but sometimes the remote site will block that and you say you don't want that. Content can be included using AJAX, but except in special cases, it must be from the same domain as the page it is being included on, then usually it's just data which then needs to be injected into the DOM of the receiving page. Server side languages like PHP and asp can be used to include content from a remote site, but the permissions on both the sites' hosts have to be set so as to allow it.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2016
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks, So How Can I Use Html/JS Load Document Of An External Webpage Using Iframe?.

  4. #4
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    It might help us understand your requirements a little better if you explain why you want to do this rather than just providing a link to the other page.

  5. #5
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Also, you should tell us whether or not the 'other webpage' that you want to include in one or more of your pages belongs to the same domain as the page(s) where you want to insert it. If yes, it can easily be done with a few lines of javascript. If not, you can use an iframe.

  6. #6
    Join Date
    Nov 2016
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks Guy's I've Figured it out by using html iframe.

  7. #7
    Join Date
    Nov 2016
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Please i'm trying 2 create a simple multiplication calculator using textarea and js function. this code is not working. i'm a noob in js.
    Code:
    <!DOCTYPE html>
    <html>
    <body>
    
    <textarea id="t1"> </textarea> X <textarea id="t2"> </textarea> = <textarea id="ans"> </textarea>
    
    <script>
    var p1 = document.getElementById("t1").value;
    var p2 = document.getElementById("t2").value;
    function myFunction() {
        return p1 * p2;
    }
    document.getElementById("ans").value;
    </script>
    <button type="button" onclick="myFunction()"> MULTIPLY </button>
    </body>
    </html>

  8. #8
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    Try this:

    Code:
    <!DOCTYPE html>
    <html>
    <body>
    
    <textarea id="t1"> </textarea> X <textarea id="t2"> </textarea> = <textarea id="ans"> </textarea>
    
    <script>
    function myFunction() {
    	var p1 = document.getElementById("t1").value;
    	var p2 = document.getElementById("t2").value;
    	document.getElementById("ans").value = p1 * p2;
    }
    </script>
    <button type="button" onclick="myFunction()"> MULTIPLY </button>
    </body>
    </html>

Similar Threads

  1. Replies: 2
    Last Post: 02-26-2012, 10:32 PM
  2. Replies: 5
    Last Post: 10-19-2011, 08:55 AM
  3. FLash Pause/play button - DONT start on Page load
    By ryanrobinson in forum Flash
    Replies: 6
    Last Post: 10-17-2011, 12:56 PM
  4. Dont Reload external content in Tab
    By ojsimon in forum Dynamic Drive scripts help
    Replies: 11
    Last Post: 07-22-2008, 03:33 AM
  5. Dynamic Ajax Content load an external website to a div-container
    By Grilly in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 07-03-2006, 01:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •