Forum Moderators: open

Message Too Old, No Replies

How Do I Override Default iFrame Target?

… ASP novice needs to know …

         

katana_one

9:04 pm on Nov 30, 2004 (gmt 0)

10+ Year Member



I only know enough ASP to use file includes. I tried looking for a HTML/JavaScript solution to this question but could not get it to work. So now I'm hoping someone can help me understand how I might create a link on one page that sends the user to a page with a iframe, and override the default source for the iframe.

Basically, its a search page in the iframe, but I want to create links from other pages that will bring up specific search results in the iframe instead.

CaseyRyan

7:55 pm on Dec 1, 2004 (gmt 0)

10+ Year Member



So, you have 2 pages.

Page 1:
page with the link.

Page 2:
page containing the iFrame. (ASP page)

scenario:
Page 1 will send data via the querystring to Page 2. On Page 2, You want to fuel the search results which are displayed within the iFrame on that page.

solution:
On Page 1, let's assume your link is something like 'page2.asp?search=searchkeywords'.

Page 2 you'll have code like this:


<%
Dim mySearchString
mySearchString = Request("search")
%>
<IFRAME SRC="http://www.searchengine.com?find=<%=mySearchString%>"></IFRAME>

The above code grabs the search string and then writes out the iFrame tag. Specifically, you will want to make sure that the SRC attribute matches the format the search engine is looking for.

-=casey=-

katana_one

1:29 pm on Dec 2, 2004 (gmt 0)

10+ Year Member



Okay, I'm with you so far, but I see a possible problem here with the formatting of the iframe's target URL.

The default URL of the iframe is in this format:

sub.domain.com/productsearch/searchhome.aspx?ID=0001&nav=no

The format for search results from this search utility are a slightly different format:

sub.domain.com/productsearch/lineresults.aspx?ID=0001&<search results string>&nav=no

Now, if I was only targeting the iframe with specific search results, this would not be a problem, but users still need to be able to navigate to the iframe normally to conduct their own searches. So I need to use the default url, and swap it out with the preset results only as needed.

Basically, on all pages on my site there is a normal link to "shop online" that brings up the default search page, and I have individual pages showing product samples and I want to link from them saying "click to see more <blue widgets>!" and have the search page open up with <blue widgets> search results.

Thanks for your help! I really appreciate it.

CaseyRyan

3:39 pm on Dec 2, 2004 (gmt 0)

10+ Year Member



Here's my new understanding:
You need one page that creates an iframe showing search results when you have a search string, else it shows the iframe with the default search page.

New code to do that:


<%
Dim mySearchString
mySearchString = Trim(Request("search")&"")

If (mySearchString <> "") Then
%>
<IFRAME SRC="http://sub.domain.com/productsearch/lineresults.aspx?ID=0001&<%=mySearchString%>&nav=no"></IFRAME>
<%
Else
%>
<IFRAME SRC="http://sub.domain.com/productsearch/searchhome.aspx?ID=0001&nav=no"></IFRAME>
<%
End If
%>

Let me know if that one works.

-=casey=-

katana_one

1:11 pm on Dec 3, 2004 (gmt 0)

10+ Year Member



Well, it took me about 30 minutes to get it working, but it is working (ampersands in the url strings always trip me up)! Thanks for your help.

It all seems so simple now.