Click here to Skip to main content
15,891,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am working in PHP MVC framework as a new commer. I have a page where I am adding link button and icon dynamically and there is an iframe control which is hidden statically. When I am clicking in my link button or in the icon on my php page it is sowing in new window but not in same window's iframe.
How can I show them in same page ?

My JavaScript for getting text, pdf or any other doc files as element:

JavaScript
<script type="text/javascript">
            function reply_clicktext(clicked_id)
            {
                var myScript = document.getElementById(clicked_id);
                var myScriptSrc = myScript.getAttribute('href');
                var doc = document.getElementById('myframe');
                //alert(name);
                //$(video).attr('src', name);
                doc.src = myScript+'embedded=true';
                doc.style.display="block";
                //video.load();
                //video.play();
                //video.height =400;
                //alert(myScriptSrc); 
                //alert(clicked_id);
            }
        </script>


My Iframe HTML code is :
HTML
<iframe id="myframe" style="display:none" width="630" height="420"></iframe>


My PHP code for calling that function reply_clicktext(clicked_id) is:
PHP
<div class="fileIcon"><a id ="<?php echo "myid" . $counter; ?>" onClick="reply_clicktext(this.id)" rel="gallery" href="<?php echo $file->getDownloadUrl() . $mime ?>&inline=1"><img src="<?php echo $file->getTypeIconUrl() ?>" title="<?php echo $file->getObjectName() ?>" alt="<?php echo $file->getTypeString() ?>" /></a></div>
Posted
Comments
UL UL ALBAB 27-May-13 6:49am    
I am using a .js file which is focusing files. But, I want to stop-focus.
UL UL ALBAB 27-May-13 8:55am    
<iframe id="myframe" style="display:block" src ="/nproject/index.php?c=files&a=download_file&1369658978&id=91&active_project=1" width="630" height="420"></iframe>

This is not showing pdf in iframe. It's start downloading.
UL UL ALBAB 27-May-13 10:21am    
No solution is here...

1 solution

If you want to show it in same frame, then follow the below methods.

1. Anchor target Property[^].

Provide the anchor target attribute to _parent or _top, which is opening the iFrame like below.
HTML
<a href="#">target="_self"><img src="referall_button.gif" alt="referall button" width="156" height="59" border="0"></img></a>


2. HTML base target Attribute[^].

Inside head of iFrame write like below.
HTML
<head><base target="_self"></head>


Note
Use either of the above methods and try with every values of target attribute. Implement which you need as per your requirement.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900