Solved

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

Posted on 2011-03-25
19
508 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
  • 11
  • 7
19 Comments
 
LVL 36

Accepted Solution

by:
SidFishes earned 500 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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 15

Expert Comment

by:myselfrandhawa
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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

15 Experts available now in Live!

Get 1:1 Help Now