Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    acc
    acc is offline
    New to the CF scene
    Join Date
    Jan 2005
    Location
    TO Canada
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    loading external file into a div

    i know this is possible, because i was able to do this already with javascript using div and innerHTML, but i encountered problems. i probably will end up using js still at an extent, but the goal is dynamic content and minimizing load time.

    what i need to do is:
    - have one page with the menus and background

    - have a number of div layers that depending on what link is clicked on, it will call on an asp page (say news/events) that will be displayed on a div layer

    - and on this external file, will still contain div layers whose content will change as well based on the links in that external file loaded


    why am i doing this?
    - especially for my company's news and press releases and other archives they have, i want one page with all the links that will show the content without refreshing every page.

    but...i don't want to use a database nor iframes and anyone know how i can change the "title" on top of the browser depending on the asp loaded?

    any help as to where i can start this off would be great!

  • #2
    New Coder
    Join Date
    Jan 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you have Response.Buffer set to True, you can use this method.

    <Title><%=Title%></Title>


    Then somewhere in your page put this
    <%
    Title = "This is this pages title"
    %>

  • #3
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    so you want to load all the pages into DIVs so that they all load at once and change instantly?

    to load a page into a DIV with asp you can either use FSO (see w3schools, search google for "asp fso reference" or use the link in my signature if it works) or use a server side include
    <div id="home"><!--#include file="pages/home.asp" --></div>
    or use
    <div id="home"><%Server.Execute("pages/home.asp")%></div>
    (all methods need to be done for every page)

    the link's onclick attribute can be used to set the visibility or position or block/inline style of the div so that it shows, and also set the title (i cant remember how you set the title but its probably something like window.title = 'home'; (in which case you dont need "window." .. its probably the same as status but with title) or document.title = 'home';

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I think you need to use an iframe.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    acc
    acc is offline
    New to the CF scene
    Join Date
    Jan 2005
    Location
    TO Canada
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    giving error

    wow, responses in this forum is much faster than other ones i'm in.

    actually, what i want to do is to load content on a div layer when called upon by a link (example: if a date in press release is clicked, the full press release will show into a seperate div layer). and as links are clicked, different content will be loaded to that same div layer.

    found a script that does this, but when i test it on our website's server it gives me "the page cannot be displayed" and the provider said that asp is supported.

    i'm a totally newbie at asp, problem is i'm trying to learn and do the work needed for our site at the same time, so please bare with me

    here's the scripts:

    declaring the cases

    PHP Code:
    <%
    Select Case p
    Case 1: %>
    < !--
    #include file="page3.html"-->

    < % Case 2: %>
    < !--
    #include file="page4.html"-->

    < % Case 3: %>
    < !--
    #include file="resume.htm"-->

    < % Case 4: %>
    < !--
    #include file="photos.htm"-->

    < % Case 5: %>
    < !--
    #include file="contact.htm"-->

    < % End Select %> 

    for index.asp

    PHP Code:
    <%
    dim p
    p=Request.QueryString("p")
    If p= "" Then
    p = 1
    End If 
    %> 

    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="CP_ACP"%>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>ASP: loading external content</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>

    <body>
    <center>
    <table width=500 border=1>
    <tr><td><a href="index.asp?p=2">trial</a></td></tr>
    <tr><td><!-- #include file="whichpage.asp" --></td></tr>
    </table>
    </center>
    </body>
    </html>

    to see what i'm talking about go to this link
    http://www.amplis.com/amplis_new/trials/index.asp

    i tried the html files in the same folder (page3.html) and it shows
    Last edited by acc; 01-19-2005 at 05:23 PM. Reason: found new info

  • #6
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts

    your link page has an error

    you need to change the page accordingly

    Code:
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="CP_ACP"%> 
    
    <% 
    dim p 
    p=Request.QueryString("p") 
    If p= "" Then 
    p = 1 
    End If  
    %>  
    <?xml version="1.0" encoding="iso-8859-1"?> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <title>ASP: loading external content</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
    </head> 
    
    <body> 
    <center> 
    <table width=500 border=1> 
    <tr><td><a href="index.asp?p=2">trial</a></td></tr> 
    <tr><td><!-- #include file="whichpage.asp" --></td></tr> 
    </table> 
    </center> 
    </body> 
    </html>

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by acc
    i want one page with all the links that will show the content without refreshing every page.

    but...i don't want to use a database nor iframes ...
    If you really want not to refresh the whole page, then you need to use iframe. The current solution you're using will refresh the page when the link is clicked. But if you want to stick with it, one workaround for dynamic include is to use FileSystemObject.

    http://www.learnasp.com/learn/includedynamic.asp
    Last edited by glenngv; 01-20-2005 at 02:00 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #8
    acc
    acc is offline
    New to the CF scene
    Join Date
    Jan 2005
    Location
    TO Canada
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by miranda
    you need to change the page accordingly
    i'm sorry but i don't exactly know what you mean by this.

  • #9
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    The @ declaration ALWAYS goes on the very first line. I must not have paid attention that it says you are using javascript as the server side page language. Because of this, the if statement would look like this.

    <%
    var p = Request.QueryString("p");
    if(p == ""){
    p = 1;
    }
    %>

    Javascript or jscript does not use the dim keyword to declare (dimension) a variable. Instead it uses var.
    Statements in javascript end with semicolon;
    If statements in javascript/jscript do not use end if.


    Also because this page is ASP with javascript as the default server side language, any (ASP not PHP) page called via an include file must also be in server side javascript, and any VBScripting would need to use script block demonstrated as such <script languge="VBScript" runat="server"> </script>. Switching in and out of the server side languages is not a good practice and the ability to use both on one page has been eliminated from asp.net.

    As glengv pointed out you need to use an iframe to have an asp page display info on it from an included php page. Likewise for a php page to display asp info. Either the asp processor or the php processor will process the page not both.

    BY The way, if from IE you click Tools > Internet Options > Advanced > and then unclick the box next to Show friendly HTTP error messages, you will see that you are given the following error

    Microsoft JScript compilation error '800a03ec'

    Expected ';'

    /amplis_new/trials/index.asp, line 4

    dim p
    ----^
    Last edited by miranda; 03-02-2005 at 06:48 AM. Reason: typos corrected


  •  

    Posting Permissions

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