Jump to content

iFrame Replacements


TGWSE_GY

Recommended Posts

Hiya Guys!

Ok here is the deal, I have a site that that I am having to use an iFrame to load content without the page reloading. However I am unable to pass url variables to the iFrame despite some people's examples on the web. So my question is what is the best alternative to an iFrame that will take url variables but will still update on say a click event on an image thumbnail, this would load the larger image in the designated area via a hyperlink attached to the thumb. I have to find something that mimics iFrames in look and feel or something that works better, but the most important part is it MUST be able to receive url variables.

:wtf:

Thanks Guys

Link to comment
Share on other sites

Ok so through some more extensive research apparently it is "impossible" to replace the functionality, or pass a php variable, or url variables to an iFrame. As a fellow developer I feel that it is unacceptable for someone to say that it is "impossible", I think that is a copout and a sign of a lazy programmer. So my question is where should I look for passing variables to an iFrame as it is becoming very annoying seeing everyone post USELESS CODE for an example of an iFrame accepting variables in php via the URL.

 

Any Ideas Guys?

 

Thanks

T!  :confused: :confused: :confused: :confused: :confused::wtf:

Link to comment
Share on other sites

Figured out a way despite being told that it is not possible or at least not easily to an iFrame.

 

Simply all you have to do is store the information that you want to be used by the page that loads in the iFrame in the SERVER $_SESSION variable and then test if(isset($_SESSION['myvar'])){$myvar=$_SESSION['myvar']; echo $myvar}else{echo "error";} on the page in the iFrame and viola you have the data that you wanted in your iFrame.

 

There you go for all who have been wondering how its done there it is.

 

Remember nothing is impossible in programming you just have to think your way around the problem! Impossible is not acceptable, but I dont know how to do it is more appropriate.

 

Thanks Again Guys,

T!

 

and remember think outside the box, you are your only limitation in programming! 8) 8) 8) 8) 8) 8) 8) 8)

Link to comment
Share on other sites

Ok so through some more extensive research apparently it is "impossible" to replace the functionality, or pass a php variable, or url variables to an iFrame.

 

Maybe missing something (there's quite a lot to read), but could'nt you just use for example:

 

src="your_file.php?var=123" ??

Link to comment
Share on other sites

MrAdam, due to the fact that either A. They didnt think about it or B. They just didnt want to offer the functionality you are unable to pass a variable in the src="" . The page that loads WILL ignore it. Through all my research I came across solutions that use divs while that is fine and dandy it lacks some key features of iFrames, 1. being that the entire page reloads, so whats the point, also needing more coding to a lot for inclusion of more than 1 file. Where as the basis of an iFrame is to allow the display of files in the frame via a link.

 

All the examples that I found did not work, and NO ONE ANYWHERE ever thought to say hey store it in a $_SESSION so that the file being loaded in the iFrame could pull that data. I am becoming more and more disconcerted with internet resources as so many claim they know but don't want to fully think out the problem, or they lack the experience there of to get the problem solved. Too many people are too quick to offer up ideas that do not achieve what people are really looking for to get them to code to standards. Well standards change, and they change from people thinking outside the box and coming up with new and innovative ways to achieve common tasks that people are wanting to get done. But as developers many of our kind are too quick to say do it this way or do it that way, with out looking at the limitations of what they are trying to use and reverse engineer a solution. I fire people from my firm for telling me something is IMPOSSIBLE that to me is not an acceptable answer as I feel that it is a lack of drive to come to a solution. Whether it be because they feel it is above them or below them I dont know. Nothing in programming impossible!

 

I have proven that you can pass a variable to a page being loaded in an iFrame. Granted you have to utilize the SERVER $_SESSION variable array, however I do not see an issue with this AS LONG as your are not storing sensitive data.

Sure some may think that iframes are no longer needed but I see a big use for them and also see where their functionality could be improved upon to offer the ability to pass variables via the src="mypage.php?variable=myvar". However to many developers I believe they see iframes as old and un-usefull.

 

Granted it took me 2 days to come up with the solution, but I got it. But enough ranting I hope that my solution can help the masses that I have seen online trying to achieve this.

 

Thanks and Happy Codeing,

T! 8)

Link to comment
Share on other sites

Quite frankly you seem pissed that nobodies done the work and given you the answer, and as a result blaming the entire web development community. In actual fact (based on my previous post (which I tested)) perhaps the problem was down to your own implementation?

 

As for using $_SESSION in that manor, strictly speaking it goes against 'good coding practices' IMO. Session variables should be for... session variables. Not to pass data between pages. Yes it works. But it's a bit of a hack, or, bad coding practices. There is another method - which is probably why nobody suggested to you to use $_SESSION - that does work.

Link to comment
Share on other sites

MrAdam

Quite frankly you seem pissed that nobodies done the work and given you the answer, and as a result blaming the entire web development community. In actual fact (based on my previous post (which I tested)) perhaps the problem was down to your own implementation?

 

First off I am not pissed that the no body did the work to give me the answer. If you look at the history of my posts I only ask to be pointed in the right direction. Under no circumstances will I allow you to make me appear like I want people to do the work for me. I own my own Firm, and I have been doing web pages since the late 90s. I assure you that I share the same mindset as many here that to expect someone to do the work for you is not acceptable use of the forums. Rather it is to gain help on problems that before you come to the forums you have researched your problem and have some understanding of what you are asking.

 

I am pissed that everything that I found on the subject was either negative(ie. it cant be done) or it can be done here is the code and the code doesnt work. There is nothing worse than people posting code saying that it works and it doesnt!

 

As far as your testing and it working, I would love to see a live working version as I have attempted many times to achieve passing a variable via the src="" but to no avail $_GET would not retrieve the variable in the file that the frame was calling.

 

Also as far as it being a hack I am already storing user session data as is so it is not a hack I just added to the data that I am tracking thank you very much!

 

Also please DO NOT put words into my mouth that I am blaming the ENTIRE Web Dev Community because that is not what I said. I said those who say/said it is impossible are the ones that irritate me!

 

I am a seasoned developer in quite a few languages web and computer application development alike. So please DO NOT assume that I want the answer handed to me. When I come to the forums for help rest assured I have spent hours trying to think my way around the problem at hand! I am only looking to be pointed in the right direction in the end and if someone throws me a chunk of code I will try it, and if works I dont just copy and paste and say oooooooooo its mine. I rewrite it making it mine, and to actually work within my application. Usually taking it farther then the person who threw the snippet of code out there  properly.

 

If you would like to continue this debate you are welcome to send me a private message through the forums and we can discuss this all day long.

 

So in short do not ever accuse me again of wanting the answer handed to me because as an experienced developer that is not only an insult but might as well be a derogatory remark to.

 

Thank You

T!

Link to comment
Share on other sites

I just tried copying MrAdarm's code and it seems to work just fine in a live example.

 

www.mystaria.com/test

 

iframe.php contains only

<?php echo $_GET['test']; ?>

iframe.html contains only

<html>
<head></head>
<body>

<iframe src="iframe.php?test=this does work!"></iframe>

</body>
</html>

Link to comment
Share on other sites

Thank You colesw I do not know why its not working on either of my dedicated web servers, I guess I need to check my php and html configuration on the server. Cause something is definitely broken.

 

I appreciate the response that it does work.

 

 

Thanks, and Happy Codeing! 8) 8) 8) 8) 8) 8) 8) 8) 8)

T!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.