JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 13th, 2012, 07:47 AM
wouz wouz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 107 wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 51 m 14 sec
Reputation Power: 39
jQuery - Link in iframe to open in a new window in an iframe, but still on my page.

I will explain it a bit.

mysite.com has an iframe with some links in it.

When you click a link in that iframe, it will open in the same iframe in mysite.com. This is not good, since I want one specific link in the iframe to open in a new window.

Not only do I want this link to open in a new window, but the new window has to be a page of my own site, with an iframe which displays the result of the clicked linked of the iframe on my homepage.

Hope you understand this, it's difficult to explain.


I am not familiar with jquery but i've searched and found something that I thought may help me a little. This is the closest topic on the web that i could find:
http://stackoverflow.com/questions/11193643/open-outgoing-link-in-iframe-by-default

I've tried the basic codes listed there to start, but i don't even know how to implement that correctly on my pages. For instance, i tried this to start:

On my index.php:
Code:
<a href="/result.php?link=http://www.google.nl">testlink.</a>


On result.php:
Code:
<iframe src="<?php echo $_GET['link']; ?>" />


As it says in the stackoverflow link i provided, but this doesn't work.


Here is my testpage.
http://www.onlineobjectives.com/vliegtest/

The iframe can be called with javascript or with the regular iframe code as you can see. I don't care for one or the other, whichever one will work the best i'll use.

If you select a flight and click 'zoeken' (which means 'search') - then it has to open the /result.php page, with an iframe which excutes the search.
__________________
woozy.

Reply With Quote
  #2  
Old November 13th, 2012, 09:48 AM
wouz wouz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 107 wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 51 m 14 sec
Reputation Power: 39
Tried another way to get a bit of a start.

This method works for everyone in this thread:
http://www.codingforums.com/archive/index.php/t-85547.html

But leaves me with a blank iframe on the new page.

Confusion is complete right now.

Reply With Quote
  #3  
Old November 13th, 2012, 08:00 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Dec 2004
Posts: 8,063 E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 1 Day 6 h 49 m 31 sec
Reputation Power: 7104
Quote:
When you click a link in that iframe, it will open in the same iframe in mysite.com. This is not good, since I want one specific link in the iframe to open in a new window.

If you have a link inside an iframe and you want it to open in the parent window instead of in the iframe, you can do so by specifying the target attribute in the HTML a tag for the link:
Code:
<a href="#" target="_parent">link</a>

Code:
<a href="#" target="_top">link</a>


If you want it to open in a new window, set the target to _blank.

Quote:
Not only do I want this link to open in a new window, but the new window has to be a page of my own site, with an iframe which displays the result of the clicked linked of the iframe on my homepage.

Your approach with result.php is correct; you would simply modify the a tags to link to result.php instead of their original link.


However, based on the way you worded your post, I'm guessing that you don't have control over the contents or <a> tags inside the pages in your iframe, and in that case what you're trying to do is impossible.
__________________
PHP FAQ
How to program a basic, secure login system using PHP
Connect with me on LinkedIn


Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #4  
Old November 14th, 2012, 04:11 AM
wouz wouz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 107 wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 51 m 14 sec
Reputation Power: 39
Hm that's too bad. Thanks for clearing it up.

Reply With Quote
  #5  
Old November 14th, 2012, 04:33 AM
wouz wouz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 107 wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 51 m 14 sec
Reputation Power: 39
One thing though. Even the simple codes when i do control the link don't work at all. How is that? For instance i changed the testpage now, check it out:

http://www.onlineobjectives.com/vliegtest/

Only code i've used is this:
Code:
<p>
<a href="http://www.google.nl" target="vidframe">Dit is 3e test.</a>
</p>



<iframe name="vidframe" id="vidframe" src="" width='250px' height='250px'></iframe>


why doesn't this even work? According to every source on the web this has to work.

Reply With Quote
  #6  
Old November 14th, 2012, 04:37 AM
wouz wouz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 107 wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 51 m 14 sec
Reputation Power: 39
aha, i think it had to do with the google link I used as a test site. I used another site and it works, so nevermind.

Reply With Quote
  #7  
Old November 14th, 2012, 09:52 AM
wouz wouz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 107 wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 51 m 14 sec
Reputation Power: 39
It doesn't look like they are willing to change the iframe. So here's what i was thinking to solve this:

Page A:
- mydomain.com/form/
Where there is a form resembling the form the site in the iframe has. But this form is on my own site, with values resembling all the values of the iframe form. But the iframe with the 'original' form is not on this page!

Page B:
- mydomain.com/search/
When clicking 'submit' on my own form on page A, it needs to go to this page B. Page B is also my own page, but here you will find the iframe. The form in the iframe needs to be filled & submitted automatically when someone fills and submits my own form on page A (matching form values).


I think this would be possible, right? I'm a long time roboform user and this standalone program doesn't care if a form is in an iframe, it fills and submits everything automatically. I assume doing something like this on a website isn't working that much different?
I am now looking into CURL as this looks like it would do what i want, never used it before though so it's new to me. Would this work?

Reply With Quote
  #8  
Old November 14th, 2012, 06:32 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Dec 2004
Posts: 8,063 E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 1 Day 6 h 49 m 31 sec
Reputation Power: 7104
Quote:
The form in the iframe needs to be filled & submitted automatically when someone fills and submits my own form on page A (matching form values).

I think this would be possible, right? I'm a long time roboform user and this standalone program doesn't care if a form is in an iframe, it fills and submits everything automatically. I assume doing something like this on a website isn't working that much different?

No, that is not possible either. JavaScript from your website is not allowed to read or write data to an iframe if the iframe src points at a different website. All interaction between your parent page and the iframe page will be blocked if the domains of the URL are not identical.

If this were not the case, then your original approach would have been possible because you could have dynamically modified the contents of the iframe to change the URLs of the <a> tags.

The fact that roboforms is a standalone program is the reason why it can do this. A standalone program runs with full privileges on the user's computer. Your JavaScript code runs with extremely limited privileges.

Quote:
I am now looking into CURL as this looks like it would do what i want, never used it before though so it's new to me. Would this work?

It IS possible to do this using cURL, or any server-side language for that matter. Effectively what you have to build is a proxy. The end user sends a request to your site, your site sends a request to the remote site, the remote site sends a response to your site, your site modifies the response and then sends it back to the end user.

Not only does this allow you to modify the HTML contents of the iframe on the server-side, but because the iframe src will be on the same domain as the parent page, you will be able to interact between the two with JavaScript also.

Reply With Quote
  #9  
Old November 15th, 2012, 09:41 AM
wouz wouz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 107 wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level)wouz User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 51 m 14 sec
Reputation Power: 39
Quote:
Originally Posted by E-Oreo
It IS possible to do this using cURL, or any server-side language for that matter. Effectively what you have to build is a proxy. The end user sends a request to your site, your site sends a request to the remote site, the remote site sends a response to your site, your site modifies the response and then sends it back to the end user.

Not only does this allow you to modify the HTML contents of the iframe on the server-side, but because the iframe src will be on the same domain as the parent page, you will be able to interact between the two with JavaScript also.


Good news, thanks for the clear answers. I've got some work to do!

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > jQuery - Link in iframe to open in a new window in an iframe, but still on my page.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap