?
Solved

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

Posted on 2011-03-25
19
Medium Priority
?
521 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:halfbaked
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 7
19 Comments
 
LVL 36

Accepted Solution

by:
SidFishes earned 2000 total points
ID: 35215198
"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
 
LVL 36

Expert Comment

by:SidFishes
ID: 35215211
(of course you'd have to switch the cfif logic for show detail if you are search for no additional details)
0
 

Author Comment

by:halfbaked
ID: 35215655
Doesn't seem to work and i'm getting an invalid markup on the cfhttp tag
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 36

Expert Comment

by:SidFishes
ID: 35215799
example works for can you post the code you are using
0
 

Author Comment

by:halfbaked
ID: 35215824
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
 

Author Comment

by:halfbaked
ID: 35215841
<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
 
LVL 36

Expert Comment

by:SidFishes
ID: 35215951
oddd. that works fine for me?
0
 

Author Comment

by:halfbaked
ID: 35216008
and you can see the benq spec sheet?
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 35216047
yep exact copy & paste of your code.
0
 

Author Comment

by:halfbaked
ID: 35216101
well i'm stumped. :(
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 35216175
can you post the error
0
 

Author Comment

by:halfbaked
ID: 35216203
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
 

Author Comment

by:halfbaked
ID: 35216220
even when i take out the cfif statement and just output the  #cfhttp.filecontent# i just get a blank page
0
 

Author Comment

by:halfbaked
ID: 35216345
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
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 35216349
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
 

Author Comment

by:halfbaked
ID: 35216545
AAAAAARG.  for some reason the '=' in the URL are being replaced '%3D' but only with this particular url?
0
 

Author Comment

by:halfbaked
ID: 35216752
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
 

Author Comment

by:halfbaked
ID: 35216753
thanks for your help
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 35216754
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

765 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