Solved

calling a dynamic page with an iframe and Javascript

Posted on 2009-04-10
2
239 Views
Last Modified: 2013-12-12
Im really stuck with this.

My Javascript knowledde is pretty much 'copy & Paste' this is the first time Ive really tried to do anything with javascript.

But I have a php file the contains dynamic data for example:
http://www.mydomain.com/my_widget.php?user_id=205&width=188&cid=0&ord=0&qty=8

That works as a page in its own right:

user_id: The users id
Width: the width of the widget
cid: Category ID - 0 if all categories
ord: order by random or newly listed items
qty: how many products to show

I basically want to use this as a widget which will contain a users shop products to display in their blogs etc. As I said the php script is working perfectly but its just the java/iframe part that is going wrong.

So thats working great and I had it in my head that I could just pop it in an iframe and call it from javascript.......

Problem 1 - I cant get the dynamic data to load in the iframe so I just get a mysql error
Problem 2 - I cant get java to call the iframe at all anyway!


Ive been searching for tutorials to help me with this thinking there would be plenty, but without luck.
########To call the widget to be inserted into blogs etc, externally from my server########
 
<script src="http://www.mydomain.com/widget_script.js" type="text/javascript"></script><script type="text/javascript">new widget.Promo(205, 188,0,0,3).renderIframe();</script>
 
 
 
 
 
 
########widget_script###########
 
 
widget = typeof(widget)=="undefined" ? {} : widget;
 
widget.Promo = function(user_id, width, cid, order, qty) {
   this.user_id = user_id;
    this.width = width;
 
   this.cid = cid;
   
   this.order = order;
   
   this.qty = qty;
}
 
   
   getURL: function(){
      return 'http://www.mydomain.com/my_widget.php'+
             '?user_id='+this.id+
	     '&width='+this.getWidth();
	     '&cid='+this.cid+
             '&ord='+this.order+
	     '&qty='+this.qty+
 
   },
   
var html = '<iframe id="promo_iframe" name="promo_iframe" allowtransparency=true style="width:100%;height:200px" src="'+this.getURL()+'" scrolling="no" frameborder="0"></iframe>';
      document.write(html);
   
}

Open in new window

0
Comment
Question by:misi_uk
[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
  • 2
2 Comments
 

Author Comment

by:misi_uk
ID: 24118816
Anyone? Even if its just to point me in the right direction of a tutorial. Im struggling to get to grips on this one.

So basically I have a dynamic php page that pulls variables from a url and I want to know how to pull that page on another server from an IFrame

Now I know you cant just stick an IFRAME on an external site so Im trying to do it through Javascript.

But not getting on to well
0
 

Accepted Solution

by:
misi_uk earned 0 total points
ID: 24119217
This has been resolved using a jQuery method.

and is finally working!
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Survey branching tutorial 11 72
Find RGB colors from a screen. 2 36
how to use a foreach loop in heredoc used to send email via php 14 31
XML loaded in a form with dropdown 6 46
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

740 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