...

View Full Version : loading external file into a div



acc
01-18-2005, 06:43 PM
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!

BrockLesnar
01-18-2005, 08:59 PM
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"
%>

ghell
01-19-2005, 11:32 AM
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';

glenngv
01-19-2005, 01:07 PM
I think you need to use an iframe.

acc
01-19-2005, 02:29 PM
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



<%
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


<%
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

miranda
01-19-2005, 08:16 PM
you need to change the page accordingly



<%@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>

glenngv
01-20-2005, 01:57 AM
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

acc
02-28-2005, 08:01 PM
you need to change the page accordingly

i'm sorry but i don't exactly know what you mean by this.

miranda
03-02-2005, 06:43 AM
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
----^



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum