Simple dashboard application - javascript

I am trying to have some fun with dashboard widgets, so I tried a simple application :
There will be a button over the widget which when clicked will open
StackOverflow website in safari.
To implement it, I tried this:
Created a custom dashboard widget.
Added a button to it from library.
Associated gotoStackOverflow handler with onclick event.
in body of function gotoStackOverflow, I wrote this code:
window.open('https://stackoverflow.com/','Stackoverflow','width=400, height=300');
When I 'Run' the application I found no browser window appearing on click of the button.
Can anyone suggest me where I may be wrong or/ and some useful links to play with dashcode and dashboard widgets?

Your code runs fine, when I recreate it. Maybe you have pop-ups blocked in Safari?

have you added
<key>AllowNetworkAccess</key>
<true/>
to the plist? if not the outside world will not be available.

I have used following code to solve my problem:
function gotoStackOverflow(event)
{
widget.openURL("http://stackoverflow.com/");
}
cheers... :)
Miraaj

Related

Open MessageBird widget chat from JS code

I'm using messagebird omnichannel widget for my website.
And put the snippet code already. The widget runs great BTW.
I did saw toggleChat function, but it can only hide the chat window.
How can I force-open the chat widget from javascript code ?
MessageBird developer is here :)
Good catch! There was a small issue with toggleChat method.
We just fixed it and deployed the fix, you can use toggleChat() now.
As you mentioned, toggleChat should do it - to open/hide the widget, but it didn't work. The issue that we had was the following:
you had to pass true to open the chat and pass false to close it. It is not obvious when we have the name of the method like toggleChat, I agree! :)
Anyway, it's fixed but feel free to reach me if you have any other questions about the widget or our other products.

Opening safari webpage from Cordova app

I'm working on an APP that consist of HTML and CSS using the Cordova framework.
There is a button that should open a webpage. The problem is that it opens the webpage inside of the app instead of safari.
My knowledge of Objective C is extremely limited (none) so I was hoping there would be a solution using maybe Javascript.
I've looked all over the internet but couldn't find a non-Objective C solution.
The button is pretty straightforward: <img src="img/button.jpg" alt="website">
I thought target="_blank" might do something for me but that (unsurprisingly) didn't work.
You can use inappbrowser plugin
http://cordova.apache.org/docs/en/3.3.0/cordova_inappbrowser_inappbrowser.md.html#InAppBrowser
Detect click on link using javascript or jquery and use this following code
window.open('http://www.google.com', '_system', 'location=yes');
I found the answer to my problem:
Opening all URL's with Cordova childbrowser
Only problem is that it automatically opens twitter.com because of the share button for some unknown reason. I'm guessing this is because of an api call it's performing upon being loaded.

Webview Link Controls for Cocoa App

Is there a way to control links in webview? The scenario is dealing with external protocol links such as mailto://, irc://, target=_blank, and anything else that may provoke a launch of a new window or app. Maybe it would pop up an nsrunalert saying that 'External links has been disabled'. Would this be something that javascript would handle or some functions within webview itself?
Thanks for any suggestions
You need to set yourself up as a WebResourceLoadDelegate and implement webView:resource:willSendRequest:redirectResponse:fromDataSource:
See http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/WebKit/Protocols/WebResourceLoadDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40003836 for more info.
Implement what buts of the WebPolicyDelegate you need. All navigation goes through there

IE and Selenium: window.createPopup()

I've been playing with Selenium lately, trying to create tests for an IE only application. Things were progressing (though slowly as without the recorder plugin I had to resort to trial and error to try to find the appropriate element paths), but now I'm stuck with a problem related to popup menues.
Most of the application actions are triggered from a popup menu created with javascript window.createPopup() and I can't seem to find a way to send events to elements inside the popup.
Maybe I should be selecting the popup like I do for windows opened with window.open(...), which are working fine BTW. I tried assigning a name to the popup menu returned by createPopup() and treating it the same way I treat windows but that doesn't seem to be working.
Does anybody knows if this is supposed to work? Any help will be appreciated.
Thanks,
Unfortunately, no. window.createPopup isn't accessible to Selenium. Being an IE only feature it has really limited portability and generally isn't a best practice. I know that's of little consolation to you, because I assume your stuck with someone else's code that's used createPopup.
The real problem is that craeatePopup doesn't add anything to the DOM. Try opening a popup object and viewing it's source. You'll see this:
<html><body></body></html>
So there's nothing really there for Selenium to grab hold of.
What does the popup do for your application? You indicated it provides some navigation, can you just navigate to those pages directly?
if you know the name of the window you can do
selenium.click("elementToLaunchPopup");
selenium.waitForPopup("nameOfWindow",30000);
selenium.selectWindow("nameOfWindow");
// rest of your test
To get back to the main window you will need to selenium.selectWindow("null");
I am using selenium 2.0b3 with InternetExplorerDriver. I found something that do the trick.
In your js save a reference to the popup window.
var popUp= window.createPopup();
Then in your java code:
public Object executeJS(String code){
JavascriptExecutor js = (JavascriptExecutor) driver;
return js.executeScript(code);
}
WebElement popUp =(WebElement)
executeJS("return popUp.document.documentElement;");
This will give you a reference to the page and you can find elements normally.

Mozilla Prism: disable pop-up blocker

I'm developing an application using Mozilla Prism. Unfortunately, Prism has its pop-up blocker activated.
I tried to disable it by inserting a line like
user_pref("privacy.popups.policy", "1");
or
user_pref("dom.disable_open_during_load", false);
into the webapp.js, which resides in the directory of the Prism application. However, this did not work, pop-ups are still not working. Any ideas?
There's a bug about this you can vote/comment on here.
https://bugzilla.mozilla.org/show_bug.cgi?id=503841
adam
I added the following lines inside prefs.js located in
For Win XP: /Documents and Settings/[username]/Application Data/Prism/[app name]/Profiles/[prism profile name]/
For Vista: /Users/[username]/AppData/Roaming/Prism/[app name]/Profiles/[prism profile name]/
user_pref("dom.disable_open_during_load", false);
user_pref("capability.policy.default.Window.open", "allAccess");
Make sure your Prism application is closed before making these changes because it will overwrite the prefs.js on close, wiping out your changes.
Finally - I can use the Gmail Create Event button to create events from my Gmail Prism app.

Categories

Resources