The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 18, 2019, 12:42:03 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Great article on using iFrames for AJAX-Like client server action...  (Read 6693 times)
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« on: May 10, 2007, 12:38:11 AM »

This outlines how you can essentially do "cross domain AJAX" using iFrames rather than the XMLHTTPRequestor. This technique definitely has a place at the table.

http://developer.apple.com/internet/webcontent/iframe.html

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
dirk
Global Moderator
Expert
*****
Offline Offline

Posts: 416


View Profile
« Reply #1 on: May 11, 2007, 07:37:32 AM »

Thanks for the link, Ed.

Yesterday I have tested a search function which is displaying
the results on the same page where the function is called in an iframe.

This is simple (as always if you know what you have to do Wink ) and works fine.

But now I want to display the search results in an iframe of
another page (another browser window).

The page should be a .html page, no .php or .cgi. Don't know if this is doable.
Currently my tests are not working.


Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: May 11, 2007, 09:30:51 AM »

Hey Dirk -

I'm gonna post a JavaScript wrapper around an iFrame call that looks like AJAX but is not hindered by cross domain stuff. I don't know if it will immediately apply, but I think conceptually it may help. But perhaps I'm way off base here - are you saying that you get results from an iframe on browser window (A) and want to display them in browser window (B)? Is this window B already open or not? Why can't browser window (b) go get it's own damn data?  Wink Guess I am unclear on what you are trying to accomplish, and whether it's an iFrame issue or a inter-browser-window issue...

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
dirk
Global Moderator
Expert
*****
Offline Offline

Posts: 416


View Profile
« Reply #3 on: May 11, 2007, 10:08:59 AM »

I will start a search on browser window a and the results should be displayed on browser window b in an iframe.

The following solution is working, but it seems to be too complicated:

Submitting the search request executes a script which stores the search phrase in a temporary file
and opens a new browser window (b) which loads a static HTML page.

The iframe of the new page execute another script which reads the tempary file to get the
search parameters. Then the database is queried and the results are displayed in the iframe.

Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #4 on: May 11, 2007, 10:19:51 AM »

By "temp file" I assume you mean a cookie? If I had to talk between two browser windows I'd use a cookie... but other than that, give what you're describing you're trying to do I don't know that I see any less complicated way. There is a nice cookie class in the Javascript repository, if you need one.

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
dirk
Global Moderator
Expert
*****
Offline Offline

Posts: 416


View Profile
« Reply #5 on: May 11, 2007, 01:18:46 PM »

I meant a normal file, no cookie. But that would imply some session handling.
Otherwise a second visitor could get the search results for the first visitor.

Found a simpler solution:

The URL of the second page is build with a query string, so the search parameter can be appended, like:

http://domain.com/page-b.html?param=keyword

Using JavaScript in page-b.html I can parse the querystring and build the iframe source URL.
Code:
<script type="text/javascript">

var param=unescape(location.search);
param=param.substring(1,param.length);

iframe_url = "search.php?" + param;
document.write('<iframe src="' + iframe_url + '"></iframe>');

</script>

The script search.php queries the database and displays the results in the iframe.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #6 on: May 11, 2007, 01:27:59 PM »

I meant a normal file, no cookie. But that would imply some session handling.
Otherwise a second visitor could get the search results for the first visitor.
OH WOW - you meant you're storing a file on your server for the second browser? I meant drop a cookie on the client machine so that the second browser window could pick it up... now I'm really confused...

can you PM me more details and I could look at where you're going? I suspect that I can assist if you are willing to share a bit more.

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!