Solved

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

Posted on 2011-03-25
19
517 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 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
Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
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 …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 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