Click here to Skip to main content
15,907,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, friends!
I have a click() method of a DOM element that makes a webpage be changed (some data are loaded but the action takes place on the same page, not in a new tab). How can I force new data be represented in a new frame on the same page?

Here is the pseudo code:

Element.click();
C#
$(document).on("click", ".classNameOfTheElement", function () {
   bla-bla-bla;
   LoadPageIntheSameTab(pathOfThePage);
    });
Posted
Comments
Afzaal Ahmad Zeeshan 7-Jun-15 7:37am    
What do you mean by new frame? Do you want a new tab or window to be opened? Because the iframe would still be on the same page; no change.
Dzianis Igaravich Leanenka 7-Jun-15 10:22am    
a new iframe tag of course

XML
<input type="button" value="Click" onclick="return loadPage()" />

<div id="target">
</div>

<script type="text/javascript">
    function loadPage() {
        var el = $('<iframe style="width:500px; height: 300px;"></iframe>');
        el.attr("src", "http://www.bing.com");

        $("#target").append(el);

        return false;
    }
</script>
 
Share this answer
 
Try out this code segment is as following,

XML
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Open web page in IFrame</title>
</head>
<body>
  <input type="button" value="click"/>
  <iframe id="myiFrame" data-src="http://www.google.com" src="about:blank">
</iframe>
</body>
</html>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
$("button").click(function(){
    $("iframe").each(function(){
        $(this).attr("src", $(this).data("src"));
    });
});
</script>
 
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