coldfusion/javascript - Reading text in frame to hide or display div

I have a page that displays a third party webpage within a iframe. depending on what is displayed on the page i need to be able to hide or display a div.  

see example page:
http://www.hardwaresaints.com/products/BENQ_Monitor_Lcd_G2020hd_20in_Wide_Full_Hd_1600x900_Glossy_Balck.html

if you click on the 'Detailed Spec' button a box appears with a spec sheet.  this is an iframe pointing to a catalog provider.  If they hold no further info the iframe page reads:

"Sorry, for this product no additional product information is found.
If you are not automatically redirected back, please click here"

ideally i want to have the spec sheet in an expandable div if it exists.  if it doesn't and the text above is displayed i want to not output the div at all.  The URL for the page with or without the detailed info in the iframe is the same for both.

Make sense? probably not.
halfbakedAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
SidFishesConnect With a Mentor Commented:
"Make sense? probably not." sounds kinda halfbaked to me :)

because of the security restrictions with iframes you can't really talk between the parent and the frame. You could however try to run a cfhttp to the 3rd party site on your page load to check for the existence of that phrase.

In the sample code I'm searching for the model number because I don't know which wouldn't have additional info . Modify the model number to g202hd to see it not display detail

for your application you just do <cfif cfhttp.filecontent contains ""Sorry, for this product no additional product information is found.">
Product Specs<br>

Stuff on your site

<cfhttp url="http://prf.icecat.biz/index.cgi?prod_id=9H.L0XLA.TBE;vendor=BENQ;shopname=openipltd">
<cfif cfhttp.filecontent contains "g2020hd">
Show Detail
<cfelse>
Dont' Show Detail
</cfif>

Open in new window

0
 
SidFishesCommented:
(of course you'd have to switch the cfif logic for show detail if you are search for no additional details)
0
 
halfbakedAuthor Commented:
Doesn't seem to work and i'm getting an invalid markup on the cfhttp tag
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
SidFishesCommented:
example works for can you post the code you are using
0
 
halfbakedAuthor Commented:
i've tested the code with a different URL with a different set of words that related to that page and it works fine.  its only when i use the icecat url it doesn't work??
0
 
halfbakedAuthor Commented:
<cfhttp url="http://prf.icecat.biz/index.cgi?prod_id=9H.L0XLA.TBE;vendor=BENQ;shopname=openipltd">
<cfif cfhttp.filecontent contains "G2020HD">
<cfoutput>
  #cfhttp.filecontent#
</cfoutput>
<cfelse>
Nothing to see here.
</cfif>
0
 
SidFishesCommented:
oddd. that works fine for me?
0
 
halfbakedAuthor Commented:
and you can see the benq spec sheet?
0
 
SidFishesCommented:
yep exact copy & paste of your code.
0
 
halfbakedAuthor Commented:
well i'm stumped. :(
0
 
SidFishesCommented:
can you post the error
0
 
halfbakedAuthor Commented:
i'm not getting an error.  instead of seeing the page content i'm getting the 'nothing to see here' comment.

if i replace the URL with a different one it works.  its almost as if it can't read the icecat url but then why can you see it.

Thanks for all your help btw.

0
 
halfbakedAuthor Commented:
even when i take out the cfif statement and just output the  #cfhttp.filecontent# i just get a blank page
0
 
halfbakedAuthor Commented:
ok...i've just hijacked someone elses webserver that i know.  when i upload my page to their server it works fine.  it must be something on our server.
0
 
Gurpreet Singh RandhawaWeb DeveloperCommented:
it might be a connection failure, if you can dump the cfhttp tag after younexceute the cfhttp tag like this

ten see what you are getting
<cfset strURL="http://prf.icecat.biz/index.cgi?prod_id=9H.L0XLA.TBE;vendor=BENQ;shopname=openipltd">

<cfhttp method="GET" url="#strURL#" useragent="#strUserAgent#" result="objGet">
 
<!--- Dump out the CFHttp response. --->
<cfdump var="#objGet#" label="CFHttp Request">

now paste ur dump here
0
 
halfbakedAuthor Commented:
AAAAAARG.  for some reason the '=' in the URL are being replaced '%3D' but only with this particular url?
0
 
halfbakedAuthor Commented:
after much messing around this works :-

<cfhttp url="http://prf.icecat.biz/index.cgi">
<cfhttpparam name="prod_id" value="9H.L0XLA.TBE" type="url">
<cfhttpparam name="vendor" value="BENQ" type="url">
<cfhttpparam name="shopname" value="openipltd" type="url">
</cfhttp>
<cfif cfhttp.filecontent contains "benq">
<cfoutput>
  #cfhttp.filecontent#
</cfoutput>
<cfelse>
Nothing to see here.
</cfif>
0
 
halfbakedAuthor Commented:
thanks for your help
0
 
SidFishesCommented:
that fails for me too so I'm sure that's the issue

try typing the whole string rather than cut & paste you may be dealing with some goofy formatting


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.