I've got an ahref that when clicked, changes the content of 3 iFrames. Here's the code:
<a href='weekone.php' target='weekone' onclick='window.open("weektwo.php","weektwo"); window.open("weekthree.php","weekthree")'>Link</a>
Now this works perfectly in Firefox, Safari etc but doesn't work in IE. Can anyone shed some light on this problem for me please? I can't use a Javascript because I'm working within a PHP framework and the iFrame links are called from the database.
UPDATE
It appears the issue lies with spaces in the URLs called from window.open! As I'm calling info from a database (ie - "weektwo.php?Name=Bob and Dave") how can I get around this??
What version of IE?
Tested on IE 8 and this worked perfectly.
<a href='test.htm' target='weekone' onclick='window.open("test.htm","weektwo"); window.open("test.htm","weekthree")'>Link</a>
<iframe name='weekone' id='weekone' width=100 height=100></iframe>
<iframe name='weektwo' id='weektwo' width=100 height=100></iframe>
<iframe name='weekthree' id='weekthree' width=100 height=100></iframe>
If you're trying to open links in an <iframe>, it's probably easier to do
document.querySelector('iframe[name="weekone"]').src='test.htm';
document.querySelector('iframe[name="weektwo"]').src='test.htm';
document.querySelector('iframe[name="weekthree"]').src='test.htm';
(I've used document.querySelector because it's the easiest, but of course you can use document.getElementById or whatever way you want to get a reference to the <iframe>.)
On the back of the comments, try adding "return true;" to the end of the onclick (untested)...
<a href='weekone.php' target='weekone' onclick='window.open("weektwo.php","weektwo"); window.open("weekthree.php","weekthree"); return true;'>Link</a>
UPDATE
In light of the updated question, try "HTML Encoding" the query strings using the PHP function "htmlentities".
I'm basing the following on your original (pre-edited) code. So in this case I apologise for asking you to edit it, but I did ask you to show exactly what was being sent to the browser...
<a href='weekone.php?Name=<?=htmlentities($i[Name])?>' target='<?=$i[Name]?> weekone' onclick='window.open("weektwo.php?Name=<?=htmlentities($i[Name])?>","<?=$i[Name]?> weektwo"); window.open("weekthree.php?Name=<?=htmlentities($i[Name])?>","<?=$i[Name]?> weekthree")'>Link</a>
UPDATE 2 (due to me being stupid)
It shouldn't be "HTML Encoding" it should be "URL Encoding" using "urlencode"...
<a href='weekone.php?Name=<?=urlencode($i[Name])?>' target='<?=$i[Name]?> weekone' onclick='window.open("weektwo.php?Name=<?=urlencode($i[Name])?>","<?=$i[Name]?> weektwo"); window.open("weekthree.php?Name=<?=urlencode($i[Name])?>","<?=$i[Name]?> weekthree")'>Link</a>
Related
Community,
I would like to run a script when you click a link, but this shouldn't open in a new frame, that's why I added the following:
<iframe style="display:none;" name="target"></iframe>
<a href="script.php" target="target">
The script now executes without popping a blank page, joy. But I want the same link to open a PDF file.
<a href="pdf/cesar.pdf" target="_blank" > click here to download </a>
But now the PDF doesn't show, as the target frame is hidden. I can't seem to combine these two. Can someone help me out on this?
Cheers!
Cesar.
It sounds like you might be over-engineering this. Consider the high-level requirements:
The link needs to:
Execute PHP code
Open a PDF file
This sounds like two actions, but from the perspective of the client it's really only one action... open the PDF file. The rest is up to server-side code.
So create one link to perform that one action:
click here to download
As long as getPDF.php returns a PDF file, the client will never know the difference. What that PHP code does before returning that file is up to you. You can have all the code you want in that file, as long as the resulting response is returning the PDF file back to the client.
With the display none it will never show up, you probably should use jQuery, I'd added an ID to the "a"
<iframe style="display:none;" name="target"></iframe>
<a href="script.php" id="openPdf" target="target">
and when click:
$(document).on("click","#openPDF",function(){
$("iframe").css("display","block");
});
This is probably a very easy question however I have been banging my head for the last week on how to solve this problem
I am using query tabs
In say tab 6 I have got a link to a php file. What I want to do is when tab 6 is opened display the url e.g. my folder/file.php?p=x&p=y&p=z .inside the tab.
I have tried the following:
<img scr="folder/file.php?p=x&p=y&p=z">
also
However noting will display
Is there anybody who can help?
thanks for looking
<img scr="folder/file.php?p=x&p=y&p=z">
Should be
<img src="folder/file.php?p=x&p=y&p=z" />
notice the typo in scr/src ^
Ok so there are tons of examples on how to pass custom parameters hidden fields in Wufoo forms (in my case the current URL of the form). The problem is these all deal with the javascript embed code. I'm working with a company whos custom backend won't allow the js embed and therefore I must use the iframe embed method. I cannot for the life of me figure out how to do this. There are a couple frustratingly close examples that mention using PHP successfully but never show the actual implementation. Can anyone tell me how to do this or point me in the right direction? Relevant info:
I currenlty have a field that is hidden using css. I want that field to be populated with the url or some part of the url it could be www.host.com/thepage or just /thepage as long as we can see where on the site the user submitted the form
http://help.wufoo.com/articles/en_US/SurveyMonkeyArticleType/URL-Modifications <- the page every post I've read mentions. http://www.wufoo.com/forums/discussion/3349/how-to-pass-dynamic-value-into-embedded-forms/p1 <- example using php but with javascript embed methodExample iframe embed code:<iframe height="763" allowTransparency="true" frameborder="0" scrolling="no" style="width:100%;border:none" src="https://username.wufoo.com/embed/formid/">Fill out my Wufoo form!</iframe>
It seems the appropriate way is to use the URL method.
Adding "def/" at the end of your src, then any arguments you wish to pass.
For example, if I wanted to disable secure SSL, I'd use:
<iframe height="763" allowTransparency="true" frameborder="0"
scrolling="no" style="width:100%;border:none"
src="http://username.wufoo.com/embed/formid/def/secure=false">
...
Additional parameters can be added using the '&' character.
(note that I also changed https for http)
In fact, if you already have a javascript example of what you want, the only thing javascript does is add this iframe for you, so if you can run it in your browser (by making a local HTML file, for example) using Inspect Element and navigating to the created iframe element, you can copy and paste the resulting code to your site, tweaking as desired.
Regarding PHP, all they mean is to construct the URL using things like echo or print. For example:
<iframe height="763" allowTransparency="true" frameborder="0"
scrolling="no" style="width:100%;border:none"
src="https://username.wufoo.com/embed/formid/def/fieldx=<?php echo $the_url; ?>">
I'm working with php to make some web pages and I'm having a bit of struggle with a link I'm trying to make.
Basically I have my <a> set with target="_self" on it so that it stays on the same page. (Note the page is a new window and that I also tried using "_top" and "_parent")
<img src="<?php echo $donnees[0]['id2_pathImgMini'] ?>" width="75" height="75" />
This is said link in its php form.
<img src="../images/propriete/DosAssorti/mini/L482_mini.jpg" width="75" height="75" />
This is the result arcoding to the browser when showing the source code.(Across IE,Firefox,Chrome)
<a target="_blank" href="http://ordi-003/inclusion/fiche.dos.assorti.info.php?id=14&lan=fr">
This is the same line according to Firebug AND the Chrome developping tools.
When clicking the linking the expected result is opening the link on the same page, however it opens it in a new window. Changing inside firebug "_blank" to "_self" and clicking the link afterwards gives the good results and opens the link on the same page.
Am I doing something wrong? Am I incorrectly using the <a> here?
Should I look for another way to make my link? I'm pretty open to anything really I tried different things and looked alot on google but couldn't find people with the same problem. Firefox cache is deactivated so that should not be the issue. Tried it on another computer too and it gives the same results.
If I gave too short information just tell me what I should also include as I am new to stack overflow.
Edit:I forgot to say that if I remove the target parameter and just put none, the "source code page" doesn't show anything like it should but in firefug and chrome dev tools it shows a target="_blank" still. Also just a note, there is only 1 copy of this file and it is on the localhost of the machine running the local site. I'm directly editing that file.
Edit2: http://pastebin.com/yrAMQEL9 be aware the indentation is awful on pastebin for some reason.
You're running different code than the code you're editing. Make sure your changes are making it to the server you're visiting in the browser and that you're editing the right file.
I finally found what was causing the replacement of my _self.
In the footer there was a script which was referenced and trough further research I found this bit of code
jQuery('a[href^=http]:not(.in)').attr({
'target' : '_blank'
});
It caused the replacement of the _self to a _blank.
Now that I know where the problem came from I just have to check with the original coder of that function why he needed it and if it is still needed.
Thanks all for your help.
I am new to Facebook and I am trying to add the Facebook like button to my website. From the developer section of Facebook, I got the following code to add the like button:
<iframe src="http://www.facebook.com/plugins/likebox.php?href=http://www.mysite.com&width=292&colorscheme=light&show_faces=false&stream=false&header=false&height=62" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:62px;" allowTransparency="true"></iframe>
Now I want to be able to place the like button on each page of my website. For this reason, I think using a static link in the above code will be useless. Hence I have my own function that populates the current page URL (including any variables that might be present in the URL) in a constant called: CURRENT_URL
So my revised code for the Like button looks like below:
<iframe src="http://www.facebook.com/plugins/likebox.php?href=<?php echo CURRENT_URL; ?>&width=292&colorscheme=light&show_faces=false&stream=false&header=false&height=62" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:62px;" allowTransparency="true"></iframe>
When I use the above revised code in my website, I dont see the Like box. Instead, I see an error page in the Iframe that says:
The page you requested was not found.
You may have clicked an expired link or mistyped the address. Some web addresses are case sensitive.
If I do a general <?php echo CURRENT_URL; ?, it is showing the correct URL. There is no problem with the value of the constant. This makes me feel that the iframe is simply trying to load the website name without parsing the constant value. I just want a code that I can use throughout the website without having to manually change the Like button value for each of the pages of my website.
So my question is:
How can I make this iframe detect the current page URL (including any variables that I may be passing via the URL) and populate the Like button URL value to the current page URL so that user can like this page.
All help is appreciated. Thank you.
UPDATE (Solution):
I found out that theres a big confusion about all this. There are actually 2 types of Like features. One is a normal Like button and the other is Like box. Here are the links:
Like Button:
http://developers.facebook.com/docs/reference/plugins/like
Like Box:
http://developers.facebook.com/docs/reference/plugins/like-box
Use the Like Button code if you want to be people to like the individual pages of your website. The Like Box asks you for: Facebook Page URL. This means that you CANNOT use it for your users to Like your web pages. (I am still working on understanding about Facebook Page URL and how it works and when it fails)
Hope this information helps anyone else going through the same trouble and confusion.
You can just echo the like button and you won't have this problems - something like that:
function likeButton($url_to_like, $action = "like") {
return sprintf('<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="%s" show_faces="true" width="450" action="%s"></fb:like>',
$url_to_like, $action);
}
I'm using the javascript version, but it's the same with the iframe :)
Using the function is a great idea. We have the same issue on our site take a look at it here (TAPNET Online Backup) because we use a common code snippet for all pages on our right side bar. I tried removing the value in href="" and it must be pulling the current URL because it is working. I see the same #'s as were there before and when I like any of the pages that weren't liked before the number increments as expected. Try that.