...

View Full Version : target frame in asp



david_stev
12-02-2003, 11:54 AM
I have a nav system that sits in a frame.

Yes I do knkow how bad frames are but this is what I have to work with.

This is set out as below

_________________
| nav |
|________________|
| |
| |
| main |
| |
| |
----------------------------

What I need to do is get the name of the main page search the string for a folder name then use that to determine what section the user is in. The appropriate navigation item can then be highlighted using this information.

This should be easy enough using
Request.ServerVariables("SCRIPT_NAME")

This howevr returns the value of the nav frame and I want the value in the main frame.

Is there a way to do this in .asp whithout having to
put .asp code on every page loaded in to the main frame of the site to pull in the SCRIPT_NAME value.


Or would I be better
A. Use Javascript completely

B. Use Javascript but pass the value to .asp (not sure how I would do this)

Thank You for any help in advance.

brothercake
12-02-2003, 12:13 PM
Please don't double-post; I've deleted this thread's duplicate.

Roy Sinclair
12-02-2003, 08:40 PM
Do you mean you've got a "search" form on the Nav window?

If so, you'll need client side javascript triggered by the submit event to fetch the name of the URL of the Main frame, place it into a hidden field that's part of your search form and then that can be submitted to your ASP script which can then use the URL from that form field to know where the user is at.

r0ck1t
12-03-2003, 12:28 AM
I think he means that he wants to get the value of "SCRIPT_NAME" and then search the value for a folder, e.g. /gallery/default.asp, so he can identify the section the user is browsing, in the example it's the gallery.

I have no idea how to do it, but now that people may understand better, they might be able to help.

glenngv
12-03-2003, 05:25 AM
If that's the case, then use:

top.frames['main'].location.pathname

Assuming the url of the main frame is:

http://www.mydomain/etc/gallery/default.asp?somequery=somevalue

...the pathname returned is:

etc/gallery/default.asp

and then from there, you can extract the path without the filename.

david_stev
12-03-2003, 08:41 AM
Thanks for your help.

What I wanted to do was find the folder that the bottom frame was in so as I could use that information to highlight the appropriate section in my navigation.

This is what I came up with. Its a combination of asp and javascript that is used to pull in the url of the bottom frame. This is then stored in a hidden text box and then submitted to the same page. This way I now am able to access the bottom frame url with asp.

If the url is blank ie if it has been submitted or not set then
doSubmit = "do"

This is required as urlPull is done onLoad in the body page by removing this step the form constantly submits.



<%
dim sUrl, doSubmit

sUrl = Request.Form("url")

if sUrl = "" then
doSubmit = "do"
end if
%>
<script language="JavaScript">

function urlPull()
{
doSubmit = "<%=doSubmit%>"

if (doSubmit == "do")
{
document.urlForm.url.value = parent.main.location.href;
document.urlForm.submit();
}
}

</script>

glenngv
12-03-2003, 08:58 AM
You can also use:

document.urlForm.url.value = parent.frames.main.location.pathname;

so that it's easier for the server to extract the path.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum