1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problems to open HTML into a DIV

Discussion in 'JavaScript and AJAX' started by guif, Jul 25, 2008.

  1. guif

    guif New Member

    Joined:
    Jul 25, 2008
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
  2. XXxxImmortalxxXX

    XXxxImmortalxxXX New Member

    Joined:
    Jun 27, 2007
    Messages:
    569
    Likes Received:
    18
    Trophy Points:
    0
    i really dont know what your asking but i found this go to the /_index.html site

    and look at the source code u see this

    **********************************CODE*************************************
    Code:
    div id="sub-panel"><a href="#" id="toggle2"><span>Información</span></a></div>
    
    **********************************END**************************************
    your # is linking to anything within the site

    for example

    Code:
    <A HREF="anameexample.html#test">test</A>
    
    maybe you should have the webpage name then add the # to it


    dunno if it helps but yea im sry i couldnt provide more information
     
    Last edited by a moderator: Jul 27, 2008
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    Just use the innerHTML to put anything into Div.
     
  4. faizulhaque

    faizulhaque New Member

    Joined:
    May 23, 2008
    Messages:
    213
    Likes Received:
    3
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Karachi
    Home Page:
    Help About InnerHTML
    Code:
    http://www.tizag.com/javascriptT/javascript-innerHTML.php
    
     
  5. guif

    guif New Member

    Joined:
    Jul 25, 2008
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    why is not possible use:
    Code:
    <a href="javascript:ajaxpage('webs/hola.html', 'section2');">Simplesection</a> 
    ?????

    If I put
    Code:
    <A HREF="anameexample.html#test">test</A>
    the page is open in a new windows but not into my DIV....
     
  6. guif

    guif New Member

    Joined:
    Jul 25, 2008
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    here is the code of javascript that i use to open a link into a DIV:

    Code:
    var loadedobjects=""
    var rootdomain="http://"+window.location.hostname
    
    function ajaxpage(url, containerid){
    var page_request = false
    if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (window.ActiveXObject){ // if IE
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP")
    } 
    catch (e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch (e){}
    }
    }
    else
    return false
    page_request.onreadystatechange=function(){
    loadpage(page_request, containerid)
    }
    page_request.open('GET', url, true)
    page_request.send(null)
    }
    
    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(containerid).innerHTML=page_request.responseText
    }
    
    function loadobjs(){
    if (!document.getElementById)
    return
    for (i=0; i<arguments.length; i++){
    var file=arguments[i]
    var fileref=""
    if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
    if (file.indexOf(".js")!=-1){ //If object is a js file
    fileref=document.createElement('script')
    fileref.setAttribute("type","text/javascript");
    fileref.setAttribute("src", file);
    }
    else if (file.indexOf(".css")!=-1){ //If object is a css file
    fileref=document.createElement("link")
    fileref.setAttribute("rel", "stylesheet");
    fileref.setAttribute("type", "text/css");
    fileref.setAttribute("href", file);
    }
    }
    if (fileref!=""){
    document.getElementsByTagName("head").item(0).appendChild(fileref)
    loadedobjects+=file+" " //Remember this object as being already added to page
    }
    }
    }
    The html is open, but not's running the css and the javascripts of my differents htmls...
     
  7. guif

    guif New Member

    Joined:
    Jul 25, 2008
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    anybody help me please?
     
  8. BrentAston

    BrentAston New Member

    Joined:
    Oct 31, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    hawaii
    Hi:crazy:

    i really dont know what your asking but i found this go it will very nice and thank u...:p
     
  9. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    BrentAston, Please confine links to signatures only and do not include them into posts.
     
  10. skp819

    skp819 New Member

    Joined:
    Dec 8, 2008
    Messages:
    89
    Likes Received:
    3
    Trophy Points:
    0
    what you want to say. if you want to know about <div> tag then you can see detail and use of <div> tag in w3schools.com.
     
    shabbir likes this.
  11. akshits

    akshits New Member

    Joined:
    May 10, 2009
    Messages:
    23
    Likes Received:
    2
    Trophy Points:
    0
    Hello,

    I don't understand what you want but still follow the steps below:-

    1> Download Prototype JS to simplify your AJAX Requests
    2> Include the file in such a way like:-

    Code:
    <script src="prototype.js"></script>
    3> Then type the following:-

    Code:
    <script>
    
    function doAjax()
    {
     new Ajax.Request("page.php",
      {method:"POST/GET", parameters:{xyz:"abc"},
       onSuccess : function(trans) { $("divID").innerHTML = trans.responseText; },
       onFailure : function() { /* Follow failure code */ },
       on404 : function() { /* File doesn't exist !! */ },
       on408 : function() { /* Request time out */ doAjax(); },
       onException : function() { /* Exception thrown */ }});
    }
    
    </script>
    
     

Share This Page