Opening IE Window from within Flex - apache-flex

All I need to open a new IE Window from within Flex code on click of a link.
P.S I dont want to open a new Browser. I want to open a browser window only that can open a new URL.
Something like clicking on a link in Flex and then open cnnibn.com in a Pop up window.

You should just be able to use:
navigateToURL(new URLRequest('http://www.cnnibn.com'), '_blank');
(make sure you import the relevant packages: "import flash.net.*")
This approach may have issues with some popup blockers, if so then you could have a look at the class here:
http://www.zorked.com/flash/flash-and-navigatetourl-popup-blocking/

One of the following methods will work unless the popup blocker blocks it.
Use navigateToURL
Add the following to the click handler of the button
navigateToURL(new URLRequest("cnnibn.com"), "_blank");
Use ExternalInterface
Add this line to click handler
ExternalInterface.call("openPopup", "cnnibn.com");
And the following to a script tag in the embedding html page
function openPopup(url)
{
window.open(url, "_blank");
}

Related

open a page to new window/tab from iframe

I have a page with an iFrame on it.
On the page in the frame I have a button.
What I want is that if the user clicks on the button, another page is opened in it's own new window or tab. This functionality is to show the user a print friendly page.
How can I do this?
This is how I now try it:
Dim sb2 As New StringBuilder
sb2.Append("window.open('")
sb2.Append(sb.ToString)
sb2.Append("','NewPFWindow','menubar=1,toolbar=1,scrollbars=1,resizable=1,sandbox=""allow-same-origin allow-forms""')")
ClientScript.RegisterClientScriptBlock(Me.GetType, "si2", sb2.ToString, True)
sb holds the page like "mypage.aspx"
Another option is to resize the iFrame so the whole page will fit. Is that possible from code-behind?
rg.
Eric
Just provide a target that has not been named on your site yet, most people will use _blank for that
I.e.
link text
or if you want to tie that to another click-event somewhere else:
window.open('desiredLocationUrl....', "_blank");
Btw. it does not matter if that link is inside an iframe ;)
found it.
Apparently Chrome uses an undocumented feature.
The frame that is trying to put the new page in it's own window or tab, needs an extra option in the sandbox property called "Allow-popup'.
This is not documented on the w3schools.com website.
So by adding this to the sandbox property, you allow the browser to create new window/tab.

set div's innerHTML with an iframe, shows up in firebug but not on page

I'm using the extjs library. I've got a blank panel and I want to load another one of my ext projects into it with an iframe. Here is my function (called from a button), "thepanel" is my blank panel.
function(button){
var div = document.getElementById('thepanel');
div.innerHTML = "<iframe src=\"../../../project2/?&type=grades&gradeitem1=40691&\"></iframe>";
}
I can see the GET request in firebug's console when I run the function and all my second project code/data all shows up in an iframe when I look a the HTML in firebug but nothing new shows up in the browser. Any ideas of what could be keeping my iframe's contents from showing
I am using MVC architecture, here is the code that declares my panel:
items:[{
xtype:'panel',
itemId:'two',
id:'thepanel',
region:'center',
}]
UPDATE: I've tried moving the iframe to the html config option of the panel instead of adding it through jquery with a button click. Again, I can see the code from the url in the iframe show up in firebug but nothing shows up in my application. Here is the code declaring my panel:
xtype:'panel',
itemId:'two',
id:'thepanel',
region:'center',
html:'<iframe src=\"../../../extjproh2/?&type=grades&gradeitem1=40691\"></iframe>',
height:400,
width:400,
Ended up using this plugin from the sencha forums:
http://www.sencha.com/forum/showthread.php?110311-iframePanel&p=943573#post943573

anchor target blank - how to always open in same popup window

I have a number of anchors in a page. I want that when the user clicks on an anchor it would open a blank window. I have used target='_blank' and that works correctly. However, I want that if the user clicks on another link in the original page, I would like that it uses the same popup that was opened for the first window. What I do not want is that the user ends up with like 10 popups as this would be a bit messy for the user.
Is this achievable please?
Any assistance would be greately appreciated.
target is deprecated since HTML 4.01, you can however use JS like this:
test
<script>
var clicky = document.getElementById("clicky");
clicky.onclick = function(){
window.open(clicky.href, "test");
return false;
}​
</script>
in the window.open, the first attribute is the URL the link should go to, the second is the name of the window, clicking any link setup like this will open in the same window.
there's better and easier ways to do this to multiple elements with jquery etc. but it all hinges on the window.open.
Instead of using _blank (which is a special value for a new window), use a name - any name would do.
target="mySpecialPopup"
When naming a window this way, every time you call it by name it uses the same instance.
Just name your target.
target='mywindow'
This should open a blank window the first click and repopulate it when other target='mywindow' links are clicked.

To disable the addressbar and standardbuttons bar in IE when my application lanches?

when my application launches in the IE from start page to main page i want to hide the addressbar and the standardbuttons bar of IE through the codebehind and here am using masterpage concept so i have to write the code in master only i think so....can anyone help for this
AFAIK you cannot disable address bar and button in IE from when the application starts unless using some ActiveX, Flash, ... Only if your application opens new window popups you could hide them.
I just found a way... It works atleast in IE 7... Not sure about other browsers...
<html>
<head>
<script>
if (window.name == 'default') {
window.name = 'Hai';
window.open('main.html', '_self'); // Current html file name
}
else if(window.name == '') {
window.name = 'Hai';
window.open('main.html', '_self'); // Current html file name
}
else if(window.name == 'Hai') {
// Use your application startup page here along with the desired options
window.open('newfile.aspx','NEWWINDOWNAME', 'Status=0, location=0');
window.close();
}
</script>
</head>
<body>
This window automatically closes itself
</body>
</html>
The complete list of options are available here.
Hope this helps.
Explanation : (AFAIK) Generally when javascript uses window.close method to close the active window, IE will ask for a confirmation from the user. Such confirmation will not be asked when the window is a popup window opened previously by a javascript along with a name.
The above just fakes the same, by opening the same file in the same window but this time with a name. As a result when window.close is executed, IE recognises the current window as a window opened using Javascript and as it also has a name, it just closes the same without confirmation.
Of course, I get a general Javascript alert at the beginning of the load, but since (I presume) you will be using aspx or other types, this problem will not be there.

Opening Pages in New Window

Is there a way to open a page in XHTML without using <a href="page.html" target="_blank"> that is standards compliant?
I'm not using frames, but there are some pages that I want to open in a new window instead of the current one.
You can use javascript's window.open() method. However this could easily be blocked by a pop-up blocker. Why do you not want to use the "_blank" target?
You can use something like this:
My Page
And then you run this jQuery:
$(document).ready(function() {
$('a[rel="external"]').attr('target', '_blank');
});
This will add the target="blank" to the links and make your HTML validate :)
Most pop-up blockers wont block a pop up that has been requested by the user e.g you click a link and it pops up a window. IF you add an onlick event to your link and a target, the desired effect will work even if JS is turned off although you don't want to use target="_blank"

Resources