Go Back   Dynamic Drive Forums > General Coding > JavaScript
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 07-19-2006, 12:29 AM
MJensen MJensen is offline
Junior Coders
 
Join Date: Jul 2006
Location: Palm Desert CA USA
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Force URL to open as IFrame in outside URL

Force orphan url open within outside url iFrame

--------------------------------------------------------------------------------

I am trying to force database search results (html) adress to open as an IFrame with-in an outside URL. Have tried using script I saw here, but it doesnt quite fit. This requires two scripts; one for the TOP/Parent page and another for the orphaned page. essentially redirectiing the orphan page to always open with-in the IFrame of the parent page.

I know this can be done as evidenced from prior feeds on this forum....
http://www.dynamicdrive.com/forums/s...ead.php?t=2354, also follow up at http://www.dynamicdrive.com/forums/s...36&postcount=4 and the code i've used is from there:

Parent >>>>>>>>>>>>
<script type="text/javascript">
var text = window.location.href;
function delineate(str) {
theleft = str.indexOf("=") + 1;
theright = str.indexOf("&");
return(str.substring(theleft, str.length));
}
url=delineate(text)

function refreshFrame() {
if(window.location!=url)
frames['maincontentarea'].window.location.replace(url);
}
</script></head><body><iframe onload="calcHeight();" name="maincontentarea" id="maincontentarea" align="left" align="top" width="85%" height="535" scrolling="auto" marginheight="0" src="main.htm" frameborder="0">


<script language="javascript">
// writes in the iframe
var contPage = (location.search.substring(1))? location.search.substring(1) : 'main.htm';
var myDomain = "shopmalm";
// now check to see that myDomain is part of the content page string
var contValid = contPage.search(myDomain);

if (contValid == -1)
contPage = "main.htm";
else
contPage = unescape(contPage);

</script>
FOREIGN URL ORPHAN>>>>>>>>>>>>>

<script type="text/javascript">
if (window == top) {
var url='window.location.replace("http://www.saintjohnlutheran.net/?var1='+window.location.href+'")';
eval(url);
}
</script>
My problem is that instead of forcing a orphan page 'main.htm" to open inside a (outside URL) page parent 'index.htm' , My orphah pages are seach results and look like this 'dwos-bin/dynamic2.pl?nccust=malmco&code=154253'
and upon reloading i get 'dwos-bin/dynamic2.pl?nccust=malmco&code=154253.htm' as the new iframe

I would be most greatful, if anyone knows the answer to this.
Reply With Quote
  #2  
Old 07-19-2006, 04:29 AM
jscheuer1's Avatar
jscheuer1 jscheuer1 is offline
No Kidding?
 
Join Date: Mar 2005
Location: SE PA USA
Posts: 18,999
Thanks: 19
Thanked 1,134 Times in 1,120 Posts
Blog Entries: 3
Default

This looks like a huge mess. I think we need to define exactly what it is that you want to have happen. Some of the terms you are using are unfamiliar to me and perhaps not the standard terms generally in use. For example, let's take just this much:

Quote:
I am trying to force database search results (html) address to open as an IFrame
This should be able to be condensed to:

I want an (html) address to open in an IFrame.

But because I'm not sure of what you are saying, I have to ask if this is really what you want, is it? Now, I know you wrote 'open as an IFrame' but, this is not really possible, 'in an IFrame' is possible, will that do?

If that much will do, all we need to know is where the iframe is and where the information as to the address is coming from and how we can capture that information and set either the iframe's href property or src attribute to the address. Sometimes it is easier or better to do one or the other, sometimes it makes no difference.

But, before I try to do all that, please answer if:

1 ) Will opening an (html) address in an IFrame do?

and, if so:

2 ) Where is the iframe or do we have to create one 'on the fly'?

3 ) Where does the address come from?

4 ) Is there more than one browser window involved?
__________________
WWWWWWWWWWWW
- John
________________________

Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Reply With Quote
  #3  
Old 07-25-2006, 09:45 PM
MJensen MJensen is offline
Junior Coders
 
Join Date: Jul 2006
Location: Palm Desert CA USA
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I hope this will clarify

1. yes. opening an (html1) address in an IFrame will do.

2. The iframe does not need to be created 'on the fly'. It exists as the
maincontentarea of another 'outside' (html2) address.

3. The (html1) address to be re-directed comes from the address
generated search results of a database located within same (html1)
address. Address (html1) example: = www datadomain.html/dwos-
bin/search.pl=id?
datafield1=text&datafield=text&sortdata=feild&pgdesign=
dynamicformated


4. Only one browser window for the (html1) address and only one browser
window for the (iframe) page address are involved. The (html1) address
will automatically open inside the (iframe) of the 'outside' (html2) address
as a result of the script I am searching for.
Reply With Quote
  #4  
Old 07-26-2006, 05:10 AM
jscheuer1's Avatar
jscheuer1 jscheuer1 is offline
No Kidding?
 
Join Date: Mar 2005
Location: SE PA USA
Posts: 18,999
Thanks: 19
Thanked 1,134 Times in 1,120 Posts
Blog Entries: 3
Default

I'm still not clear on this, where you say:

Code:
www datadomain.html/dwos-bin/search.pl=id?datafield1=text&datafield=text&sortdata=feild&pgdesign=dynamicformated
That is neither a valid URL or a valid search string. It could be a valid search string if it was www%20datadomain except that, just as a rule of thumb, www is a poor choice as a portion of a filename which, is what it looks like it would be if the above were a search string.

Perhaps you have a typo or are trying to convey something with the colors used for the example that has gone over my head.

In any case, if this is server side code, why can't you have the server side language take the query results and convert them to a server side redirect. If this is done on a page already in an iframe, the redirect should then populate the iframe.
__________________
WWWWWWWWWWWW
- John
________________________

Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Reply With Quote
  #5  
Old 07-26-2006, 04:23 PM
MJensen MJensen is offline
Junior Coders
 
Join Date: Jul 2006
Location: Palm Desert CA USA
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I could perhaps do so, but it would, if i understand correctly, require re-writing code for hundreds of pages. None-the-less, you have identified what it is im looking for, and on a previous occassion provided script almost identical to another student. That thread can be found here:

http://www.dynamicdrive.com/forums/s...ead.php?t=8567

The only difference is that the prior student was re-directing an (htm) into another (htm) and in this case it's a searchstring to an (htm). Can this be done?
Reply With Quote
  #6  
Old 07-26-2006, 06:49 PM
jscheuer1's Avatar
jscheuer1 jscheuer1 is offline
No Kidding?
 
Join Date: Mar 2005
Location: SE PA USA
Posts: 18,999
Thanks: 19
Thanked 1,134 Times in 1,120 Posts
Blog Entries: 3
Default

If I give you a javascript to do this, I would think that 100's of pages would need to have the script on it as well then, the only difference is that it won't work in as many browsers.

Or maybe not, if a javascript can do it without editing 100's of pages, then a redirect should also be able to do it without editing 100's of pages.

The redirect would go on the page in the iframe. It would test its own query string and redirect if certain conditions are met.

But, though I am not real strong on server side languages, I seem to remember that, at least in ASP/VBscript, that a page cannot redirect on the basis of a query string because it is basically too late to do so once the query string is read.

Anyways, I didn't mean to say I wouldn't try to come up with a javascript solution for this. Just that a server side solution would be superior. As I recall no server side coding was involved in the thread you are referring to.

I just checked, it wasn't. OK then, the script information in that thread when used with the information that thread links to (added to the content and top pages) will force a page that is intended to be in an iframe into its iframe if it is navigated to individually. How is your situation different?

Additionally, if modifications are needed, I still need a better understanding of the query string you have to work with. What you have supplied so far looks to me as though it isn't a valid url. No redirection can be done in any language if the destination url isn't known.
__________________
WWWWWWWWWWWW
- John
________________________

Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Reply With Quote
  #7  
Old 07-27-2006, 03:28 PM
MJensen MJensen is offline
Junior Coders
 
Join Date: Jul 2006
Location: Palm Desert CA USA
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is where my limited script knowlege breaks down, and so I'm not sure how to respond. Perhaps knowing that the search result pages all use one teplate helps you to see why id rather re-direct the (to be) iframes.

Ok so here's what happens when i use the (htm) to (htm) script referred to in a prior thread for the query page URL>

SCRIPT LANGUAGE='javascript'>
/* try { if (top == self) {top.location.href='index.html'; } } catch(er) { } */
if (window == top) {
var url='window.location.replace("index.html?var1='+window.location.href+'")';
eval(url);
}
</SCRIPT>


I get a redirect address:

domain1.htm?var1=domain2.htm/dwos-bin/queryx.pl.nccust=malm&field1=text&field2=text&sortby=text.htm

How can i stop the addition of .htm to this address


And what script will ensure that it writes into its target iframe named="maincontentarea" on the parent page. Prof. Scheuer, thank you for staying with me..I hope im answering as consisely as possible and am most gratefull for your time....

Does this bring us to the next level?
Reply With Quote
  #8  
Old 07-27-2006, 08:27 PM
jscheuer1's Avatar
jscheuer1 jscheuer1 is offline
No Kidding?
 
Join Date: Mar 2005
Location: SE PA USA
Posts: 18,999
Thanks: 19
Thanked 1,134 Times in 1,120 Posts
Blog Entries: 3
Default

Somewhat but, we may have a deal breaker. Javascript, and for that matter any server side languages as far as I know, cannot work across domains in certain situations where iframes or frames are concerned. Because this situation is different than any exact situation I've encountered before, this may not matter, we would have to try it out but, just because it might seem to be working at first doesn't mean that it might not break down as it is extended to additional page loads. The error(s) it throws (if any) would be my final guide to if this is a problem or not.

Now, I am not even sure that more than one domain is involved here but:

Quote:
Code:
domain1.htm?var1=domain2.htm . . .
Seems to indicate that there might be. But, like www, domain is a poor choice of filename. If these really are domains then domain1.htm isn't a valid filename so I am back to square one, not knowing what the url really looks like.

Further, since what you seem to want is this:

You have a page inside an iframe. You click on a link on that page and want the page that is navigated to as a result to be displayed within that same iframe.

That can be achieved with an ordinary link on the page in the iframe. Perhaps you are over thinking this.
__________________
WWWWWWWWWWWW
- John
________________________

Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Reply With Quote
  #9  
Old 07-27-2006, 08:58 PM
Twey's Avatar
Twey Twey is offline
Modtoreador
 
Join Date: Jun 2005
Location: 英国
Posts: 11,933
Thanks: 1
Thanked 180 Times in 172 Posts
Blog Entries: 2
Default

Quote:
and for that matter any server side languages as far as I know, cannot work across domains in certain situations where iframes or frames are concerned.
Server-side languages do not have a domain restriction. Only local data that is not included in the output is unavailable when obtaining a document from another server (such as variables).
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Reply With Quote
  #10  
Old 07-27-2006, 09:07 PM
MJensen MJensen is offline
Junior Coders
 
Join Date: Jul 2006
Location: Palm Desert CA USA
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oh :>(
I've looked at the sites where javascript was used in this scenario previously, and them seem to work without flaw. With regard to links, yes they already exist outside the maincontentarea of the TOP page.

Would it be easier if I provided the actual site addresses involved or does this work?

IFRAME PAGE URL

(DOMAIN#1).COM/INDEX.HTM

SEARCH QUERY PAGE

(DOMAIN#2).COM/DWOS-BIN/QUERYX.PL?NCCUST=MALMCO&CATEGORY=FURNITURE&NAME=DESK&SORTBY=CODE
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:13 PM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.