FileReferenceList: Forcing browse() dialog box to stay on top - actionscript-3

This is probably going to be a simple question, but I can't seem to find my answer online after searching.
I am using the following simple code:
var fileReferenceList:FileReferenceList = new FileReferenceList();
fileReferenceList.addEventListener(Event.SELECT, onSelect);
fileReferenceList.browse();
A big flash button triggers this code, which works perfectly fine. Unfortunately, I don't enforce that the button cannot be clicked while the dialog box to browse file is opened, so I get "Error: Error #2041: Only one file browsing session may be performed at a time." if I click on the button while the pop up dialog box is up.
A solution that I really like is the one that Google Docs has. It does not let you click on their button, above "Select files to upload" while the pop up dialog box is showed. Actually, this dialog box has a sort of priority: You can't click ANYWHERE on the page before you select files or cancel on this dialog box.
I would like to have the same behavior, not let the users click anywhere in my web page until this dialog box is done, just like Google Docs does it, but I can't seem to find how.
Any clue from anyone please?
Thank you very much,
Rudy

You should take a look at the HTML file that embeds the SWF. In Windows/Firefox, the behavior of the "select file" dialog will differ depending on what Window Mode (wmode) you use in the EMBED tag in the HTML page.
If you use wmode="opaque" or wmode="transparent", then the "select file" dialog will not be modal, and you'll be able to click on the browser window itself to bring it to the foreground. (Also, you'll be able to minimize and even the browser window). This only seems to apply to Windows/Firefox; other browsers all appear to keep the "select file" dialog on top.
If you omit the wmode attribute (it defaults to "window"), or set it to "direct" or "gpu", then the "select file" dialog will be modal.
Modal "select file" dialog:
<embed src="Upload.swf"
wmode="window"
quality="best"
scale="noscale"
swliveconnect="true"
salign="lt"
width="220" height="75" bgcolor="#ffffff"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
Non-modal "select file" dialog:
<embed src="Upload.swf"
wmode="opaque"
quality="best"
scale="noscale"
swliveconnect="true"
salign="lt"
width="220" height="75" bgcolor="#ffffff"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>

The Google Docs browse dialog is "modal" (meaning the focus can't go to anything else while the dialog is up). As far as I can tell, the FileReference dialog box should be modal by default. What browser are you testing this in?
As a workaround, you could put a transparent (or semi-transparent, for a dimming effect) overlay over the entire stage while the dialog is up. This won't prevent the focus changing, but it will prevent other buttons on the stage from being clicked. For example a class like this:
public class Overlay extends Sprite
{
private static const BACKGROUND_OPACITY:Number = 0.40;
public function Overlay(_stage:Stage)
{
graphics.beginFill(0x000000, BACKGROUND_OPACITY);
graphics.drawRect(0, 0, _stage.stageWidth, _stage.stageHeight);
graphics.endFill();
}
}
That would be used like this (from the document class):
private var overlay:Overlay;
public function onButtonClick(e:MouseEvent):void
{
overlay = new Overlay(stage);
stage.addChild(overlay);
// ...
fileReference.browse();
// ...
}
public function onSelect(e:Event):void
{
stage.removeChild(overlay); // Also do this on cancel, and on errors
}

Related

Open new browser window with "Always on top"

I know that this is not a good practice :-) but I have a request to open a new browser window which is "always on top". It is a small notification/statistics window and not an ad pop up.
I tried with open a new window from main page:
<a href="okence.html"
onclick="window.open('okence.html', 'newwindow', 'width=400,height=320'); return false;"
>Click</a>
The new html file has:
<html>
<body>
<script type="text/javascript" language="javascript">
onblur = function() {
setTimeout('self.focus()', 100);
}
</script>
Test
</body>
</html>
The new window opens, but doesn't have "always on top". Is there any other way? Or maybe browsers don't allow that?
I have tried some suggestions (also set the focus of a popup window every time) but none of them works. New (small) window is opened, but if I click somewhere outside, its gone behind. I want a classic "Always on top" feature, where window stays on screen.
You can't do this. It's a huge security issue if sites could do this! Scammy web sites could keep visitors from de-focusing the window.
Think about it:
What if your e-mail program stuck a pop-up in your face every time you received a new e-mail message? If you don't like it, you will want to minimize it or at least hide it behind some other window. Problem is, what if you can't hide it behind another window? This ruins user experience.
Instead, try:
flashing the title bar (like Gmail when a new Hangouts message is received: title bar flashes from "Gmail - Inbox" to "<name> says..."). Like this: The code is below. Make sure to stop running the snippet when you're done by clicking Hide Results to make sure the snippet stops draining your RAM by flashing a title.
setInterval(function() {
var title = document.getElementById('title');
if (title.innerHTML === "Original Title") {
title.innerHTML = "New Notification!";
} else {
title.innerHTML = "Original Title";
}
},1000)
<p id="title">Original Title</p>
<small>Because Stack Snippets don't have <title> support, I used a p element there. In real development, replace <p> with <title>.</small>
adding a red dot to the favicon, so the user can see there is a notification when they glance on the tab bar. Code:
setInterval(function() {
var flash = document.getElementById('flash');
if (flash.src == "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgklEQVQ4Ed2RSw6AMAhEOYhLT+7p3HiGGjRTp0OxJrpyQeiH9yhqtqzlVaSwWTGOrFEQAOoBfqfnzUGvIAAiqYInMGRc+42AjegyymCOF2AzgvgezF8EPhtm4jllvU1zQVx/D0U3AkCaz+8HgedEoiDvrT4FIpeIiAFdR4GKSMgwGu91q05tY4o1SAAAAABJRU5ErkJggg==") {
document.getElementById('flash').src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAdklEQVQ4Ed2RQQ6AMAgE+f8zfJ2/qME4zbqV1MSePDQU2FlKGrHt7dMp4YgWeqpBgwHQE5A9r98KT4IBMJNu8AbGTLVrDNSRKbMIc76AZAZpH+YvBrkbO+me1V21a76RSepMzaNr+gsQpsBF2SvrgB4BiN6/8gPOhlAtW0V8NgAAAABJRU5ErkJggg==";
} else {
flash.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgklEQVQ4Ed2RSw6AMAhEOYhLT+7p3HiGGjRTp0OxJrpyQeiH9yhqtqzlVaSwWTGOrFEQAOoBfqfnzUGvIAAiqYInMGRc+42AjegyymCOF2AzgvgezF8EPhtm4jllvU1zQVx/D0U3AkCaz+8HgedEoiDvrT4FIpeIiAFdR4GKSMgwGu91q05tY4o1SAAAAABJRU5ErkJggg==";
}
},1000);
<small>Once again, stack snippets does not support favicons. In real development, change img to link.</small>
<img rel="icon" type="image/png" id="flash" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgklEQVQ4Ed2RSw6AMAhEOYhLT+7p3HiGGjRTp0OxJrpyQeiH9yhqtqzlVaSwWTGOrFEQAOoBfqfnzUGvIAAiqYInMGRc+42AjegyymCOF2AzgvgezF8EPhtm4jllvU1zQVx/D0U3AkCaz+8HgedEoiDvrT4FIpeIiAFdR4GKSMgwGu91q05tY4o1SAAAAABJRU5ErkJggg==" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgklEQVQ4Ed2RSw6AMAhEOYhLT+7p3HiGGjRTp0OxJrpyQeiH9yhqtqzlVaSwWTGOrFEQAOoBfqfnzUGvIAAiqYInMGRc+42AjegyymCOF2AzgvgezF8EPhtm4jllvU1zQVx/D0U3AkCaz+8HgedEoiDvrT4FIpeIiAFdR4GKSMgwGu91q05tY4o1SAAAAABJRU5ErkJggg==" />
What to avoid:
playing a huge sound when a new notification arrives
trying to force user activation (fortunately, most browsers block this)
lastly, opening a popup window.
So popups are not such of a good idea.

Switch to Previous IFRAME Selenium Python

I am trying to switch to the previous frame.
In my code
I switch to a frame (BRCT1Frame),
Click a button that opens a new window
Switch to a new window
Switch to the frame inside of the window
Insert data & save which closes both the window and frame
However, there is a frame that is before the BRVT1Frame that I need to switch to.
Here is My Code:
BRT1Frame=driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
buttons=driver.find_elements_by_css_selector("button")
for button in buttons:
if button.text.strip()=="Create Community":
button.click()
#A new pop up window causes me to switch windows
for handle in driver.window_handles:
BRT=driver.switch_to_window(handle)
print(BRT)
#then I switch frames
driver.switch_to_frame(driver.find_element_by_class_name("FormDialogIFrame"))
driver.find_element_by_id("CommunityFormCommunityNameTextBox").send_keys("1st MEB STAFFEX")
save=driver.find_element_by_id("CommunityFormSaveButton").click()
#that popup closes now I have to switch to another frame
The frame I am trying to switch to code:
<iframe role="presentation"
class="x-component x-window-item x-component-default"
src="/brvt?lang=en_US&owf=true&themeName=a_default&
themeContrast=standard&themeFontSize=12"
name="{"id":"778a1259-bc80-602e-c0ad-16a3f9220516","containerVersion":"7-GA","webContextPath":"/owf","preferenceLocation":"https://www.url,com;,"relayUrl":"https://url.com/55js/even/rpc_relay.uncompressed.html","lang":"en_US","currentTheme":{"themeName":"a_default","themeContrast":"standard","themeFontSize":12},"55f":true,"layout":"desktop","url":"/brvt","guid":"260f0022-66de-a78b-3ce8-8de63a3bdbec","version":1,"locked":false}"
id="{"id":"778a1259-bc80-602e-c0ad-16a3f9220516"}"
frameborder="0"></iframe>
I have tried to do this:
driver.switch_to_frame(driver.find_element_by_tag_name("iframe"))
this worked but when I tried to click a drop down menu inside of the frame:
driver.find_element_by_css_selector("#OYk3vd6NKj1jbrnew > td.sub_item_text").click()
I have also tried:
driver.switch_to_frame(driver.find_element_by_id("{"id":"778a1259-bc80-602e-c0ad-16a3f9220516"}")
I get an error that states that it is unable to locate the element.
Suggestions?
If you just want to locate exact frame that you specified, then try:
required_frame = driver.find_element_by_xpath('//iframe[#role="presentation"]')
driver.switch_to_frame(required_frame)
or even more specific:
required_frame = driver.find_element_by_xpath('//iframe[#role="presentation"][#class="x-component x-window-item x-component-default"]')
driver.switch_to_frame(required_frame)
Does this advise was helpful?

How to I stop right mouse click on my website

i would like to disable a user from right mouse clicking on an embedded youtube video.
How to I do this ?
1st Way:
We can set the oncontextmenu="return false" in the tags of the HTML page where you have embedded youtube video
so HTML part will probably look like
<{tagname} oncontextmenu="return false">
...
</{tagname}>
2nd Way:
In this way we add a JavaScript method, in this we check if click is right click or left click if it is right click then a message is displayed like "Right click disabled".
Set an id where you have added code for embedded youtube video. Add this Script in the HTML Document for that id.
<script language="javascript">
document.getElementByID({idname}).onmousedown=disableclick;
status="Right Click Disabled";
Function disableclick(e)
{
if(event.button==2)
{
alert(status);
return false;
}
}
</script>
Note: In this solution if you click the right click it displays the message:
“Right click disabled”
If we want to remove the message box then this solution do not work.
*Replace {...} with appropriate names.
Reference: Click here

Opening template html in a new window from UiApp Script

I have a UiApp script that display images in flextable; I have assigned mousedown handler to the images so that when it is clicked I want it to open a templated HTML page (in a new window). I wrote the following code; it gets executed but it doesnt return anything.
What should I do to get the Item Detail page containing the image loaded from the imageurl assigned to be opened in a new window?
Here's my script and html code:
var page = HtmlService.createTemplateFromFile("Item Detail");
var image = productDetails[i].imageurl;
page.imageurl = image;
Logger.log(productDetails[i].imageurl);
return page.evaluate();
<img src=<?=imageurl ?> alt="click for more info" height="100%" width="100%">
So suppose you want to make a clickable image. And you want this image to open in a new window when you click on it.
var anchor = app.createAnchor("<img src='URL_TO_IMAGE' />",
true,
ScriptApp.getService().getUrl()+"?detailPage="+SOME_ID)
.setTarget("_blank");
Then when you click on that link, your script will be opened in another window. And also, a GET parameter will be passed along with it. So in your doGet(e) function, you could handle whether to display the main UiApp or an Html detail page.
function doGet(e) {
if (e.parameter.detailPage) {
//show the detail page
} else {
//show the normal UiApp
}
}
Read the top part of this other answer to get a better idea of how GET parameters work with GAS.
You will want to surround the <img> with a <a> tag.
<img ... >

Run function on popup close - flex

I've got a flex project that I'm working on. Currently I've got a popup that consists of another mxml file containing a form.
Once the form is filled in and submitted I'd like to run another function then the popup closes on the main mxml file, but I'm not sure how to go about doing this?
Here's my popup code:
private var weightadd:weight_add; //POP UP ADD WEIGHT FORM
private function weightAdd():void {
weightadd = new weight_add();
PopUpManager.addPopUp(weightadd,this,true);
PopUpManager.centerPopUp(weightadd);
}
Currently in my weight_add.mxml file I'm using a button to close the popup, I'd like have this button close the popup and then call a function in my main.mxml file - I'm just wondering how I go about doing this.
<mx:Button x="186" y="83" label="Cancel" styleName="formbutton" id="cancel_button" click="PopUpManager.removePopUp(this);"/>
I found this example which seem to do the trick
http://bubutripathy.wordpress.com/2007/02/09/popup-login-window