Solved

stop Iframe Redirect

Posted on 2006-07-20
14
2,546 Views
Last Modified: 2008-08-15
ok so here is the thing... i have been looking over the site and i can't find the answer anywhere.  I am building a site in html, the site is for someone with an ebay store.  within their site, i used and Iframe to show their store instead of a link.  when it goes to that page, you only see it in the frame for about 2 seconds, then ebay takes it over, and the whole page gets redirected to the store.  you can't even go back to the website.  here is the code i am using.... <IFRAME name=ebay src="http://stores.ebay.com/BACKDROP-OUTLET" width=800 height=600
> content
 if browser does not support </IFRAME>

I need it to STAY in the frame and not leave the site.... I don't even know if what I am trying is possible.
please help as this is sooooooooooo important.  thanks
0
Comment
Question by:justfurious2k3
  • 8
  • 6
14 Comments
 
LVL 19

Expert Comment

by:nschafer
Comment Utility
Hi justfurious2k3,

The most likely reason for the results you are getting is that the store has a frame-busting script built into it.  Glancing quickly through the source for the page I don't see it, but since there are a few external scripts being called it could be in one of them.  It is difficult to get around this.  The whole point of frame-busting is to prevent exactly what you are trying to do.  

If you look at the following question it may give you a start on how to do this.

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21707999.html

Hope this helps,
Neal.
0
 

Author Comment

by:justfurious2k3
Comment Utility
i want you to know i have already discussed this WITH ebay and they told me that if i could find a way to do it, it's ok but they couldn't help me.  at any rate.. I am not the biggest programmer.  from your link I found a code i think you are saying can help.  this is what i have...

frameshow.html
--------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Show page in frame</title>
<script type=text/javascript>
function getPage(){
  window.frames[0].location = "frameshow.asp?url=" + document.getElementById('url').value;
}
</script>
</head>
<body>
<input type=text id="url" size=50/>
<input type=button onclick="getPage()" value="Get Page" />
<iframe name="i1" id="i1" width="100%" height="400" src="about:blank"></iframe>
</body>
</html>

my question for this is I don't see where I would be putting in the store url.  I mean i see some url spots but does it go where ever i see "url"?  thanks!
0
 
LVL 19

Expert Comment

by:nschafer
Comment Utility
justfurious2k3,

The question that I pointed to had a couple of things going on differently than yours.  Specifically the URL was being entered by the user.  In your case you will want to hard code the URL.

  window.frames[0].location = "frameshow.asp?url=http://stores.ebay.com/BACKDROP-OUTLET";

The other things to keep in mind, as I had mentioned in that post.  The method used is to use an ASP page to strip out the Scripts.  This could be done without ASP, but the code at the question I pointed to uses ASP, so make sure you have the ability to process ASP pages.  If not, this can be re-written to not require it.

What might be a bit of a larger problem for you though is that the idea here is to remove all scripts from the page before showing it in the frame.  This might be a problem for you because you likely need some of those scripts for the store to work properly.  We may be able to be more selective in removing the scripts, but it will take a bit of work to look at the running code and determine how to properly eliminate only the frame-busting script.

Neal.
0
 

Author Comment

by:justfurious2k3
Comment Utility
Neil you are really informative and i appreciate it!! thanks!  now is there anyway you can give me an example of the exact code I would need to put in?  thanks again you rock

Dutch
0
 

Author Comment

by:justfurious2k3
Comment Utility
neal,  I was using the wrong ebay store and I apologize.  here is the new frame HTML i am trying to use

<IFRAME name=ebay src="http://stores.ebay.com/Decorative-Fabric-Outlet"
 width=800 height=600> content if browser does not support </IFRAME
>

i am soo sorry about that but this is THE store we are trying to do it on...  thanks again!
0
 
LVL 19

Accepted Solution

by:
nschafer earned 500 total points
Comment Utility
justfurious2k3,

Here is some simplified code that will allow the store to load into a frame:

1st Page has the iframe:
----------------------------------------
<!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>Untitled Page</title>
</head>
<body>
<iframe src="frameshow.asp" style="width:80%;height:300px;"></iframe>
</body>
</html>
--------------------------------------

2nd page   :frameshow.asp
--------------------------------------
<!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>Untitled Page</title>
</head>
<body>
<%
dim vURL
vURL = request.querystring("URL")
vURL = "http://stores.ebay.com/Decorative-Fabric-Outlet"
if vURL > "" then
  ' Note XMLHttp Example from 4GuysFromRolla.com
  '
  Response.Buffer = True
  Dim objXMLHTTP, xml, txt, v

  ' Create an xmlhttp object:
  Set xml = Server.CreateObject("Microsoft.XMLHTTP")
  ' Or, for version 3.0 of XMLHTTP, use:
  ' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")

  ' Opens the connection to the remote server.
  xml.Open "GET", vURL, False
     
  ' Actually Sends the request and returns the data:
  xml.Send
   txt = xml.responseText
   ' kill all scripts
   txt = replace(txt,"<script","<!--<script")
   txt = replace(txt,"</script>","</script>-->")
'  Response.write "<xmp>"
   Response.Write txt
'  Response.write "</xmp>"

  Set xml = Nothing
end if
%>

</body>
</html>
----------------------------------------------------------


Neal.
0
 

Author Comment

by:justfurious2k3
Comment Utility
NEAL!!!!! You are the coolest!  thank you sooo much.  I have already posted it and you can look at it at www.truspecmedia.com/fabric.html also i was wondering though, withing the ebay page i see some things like "-->"  is that because some code was stripped?  thanks you rock!!!!!!!!!

Dutch
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:justfurious2k3
Comment Utility
ok wait one more thing... if you go onto www.truspecmedia.com/fabric.html  and play around a little in the store (click contact or search something within store)  you will notice that it will bust out after a few clicks... anything we can do about that?  thanks!
0
 
LVL 19

Expert Comment

by:nschafer
Comment Utility
I'm not sure why the "-->" is showing up, but it is possible that it's because the scripts look something like this:
  <script>
  <!--
   ....
   ....
  -->
  </script>

The code I added above would convert this like this:
  <!--<script>
  <!--
   ....
   ....
   -->
  </script> -->

What happens here is that it is commenting out the script.  Often scripts will have <!--   --> within the script to prevent the script from being displayed as text in old browsers that did not support scripting.  Since the --> ends the comment, the </script>--> are outside the comment area.  

I can't really think of a way off the top of my head to prevent this.  If the script does not have <!-- --> in it then this isn't a problem, but with it there this will occur.  

Perhaps a different method could be used rather than just commenting out the scripts they could be removed altogether.  Something along the line of this.

Instead of these lines:
   txt = replace(txt,"<script","<!--<script")
   txt = replace(txt,"</script>","</script>-->")

This might work:
nStart = instr(txt,"<script")
do while nStart > 0
  nStart = instr(txt,"<script")
  nEnd = instr(txt,"</script>")
  if nStart > 0 then
    txt = left(txt,nStart -1) & right(txt,len(txt)-nEnd -8)
  end if
loop
 
The problem with the page busting out of the frame is because the links embeded in the page don't go through the frameshow.asp page.  We might be able to do another replace, to replace the href's in the page, but the consistancy of the formating of the code for the links might be a problem.

Neal.
0
 

Author Comment

by:justfurious2k3
Comment Utility
Neal,  I can not tell you how BIG of a help you have been.  Please know how much i appreciate you working on this.  I am even willing to throw you some of my comission if it would help you.  do you think it is even possible to pull this off?  I know it is difficult but i would appreciate anything you could do to help me keep this in the frame no matter what is clicked within it.  thanks so much!

Dutch
0
 

Author Comment

by:justfurious2k3
Comment Utility
ok another message, is there anything we CAN do about the consistency of the code?  i mean keeping it straight through so ebay stays within the fram 100%?  like i said i am willing to give you some of my comission if we can do this.  thanks again for all your effort!
0
 
LVL 19

Expert Comment

by:nschafer
Comment Utility
Dutch,

Thanks for the offer, but paying for results would be against the policies of this site.  It could  also potentially open me to some liability.  The experts here are all volunteers and we provide no gurantees that our solutions will work (although we certainly try).  Once money changes hands things can get a bit more difficult.  But as I say, thankyou for the offer.

I've looked at the code and it appears that ebay is very consistant in how they put in the hyperlinks.  I put some code in to replace the hyperlinks with a call back to the frameshow.asp page.  The script was successful at changing the hyperlinks, however a problem I hadn't thought of came up.  By going through the frameshow.asp page we are working across domains (your domain and ebay's domain)  As soon as I clicked on one of the links I received an access denied error.  Offhand I can not think of a solution for this.  This is a basic security issue that has been built into browsers / web-servers.

I'm not going to say that this would be completely impossible, but I don't see a solid solution at this point.

By the way I used the code I posted above to remove the scripts instead of commenting them out and this did work, but we still have the problem that it is only good for the first page.

Neal.
0
 

Author Comment

by:justfurious2k3
Comment Utility
BIG OOPS ON MY PART!!!  i don't want to go against the policies (remembe i'm still new to this site)  i totally understand everything you are saying... thanks so much for all the help.  I can't tell you how much appreciate it!

Dutch
0
 
LVL 19

Expert Comment

by:nschafer
Comment Utility
No problem.  I wish I could think of a way around it breaking out of the frame (the sign-in page is where I noticed it) but frankly I just can't seem to think of anything that will do it.

Neal.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now