Full screen Silverlight through javascript - javascript

Ok this is the problem. I have a basic web site, which has buttons. those buttons are run through javascript and then the code goes in C# and then it does various things with the Silverlight gantt control.
For example if I want to ZOOM IN the gantt control I go like this:
<button id="zoomIn" onclick="SlZoomIn()">Zoom In</button>
then in javascript:
function SlZoomIn() {
var control = document.getElementById("SilverlightPlugIn");
control.Content.SilverPlan.JsZoomIn();
}
then in C#:
[ScriptableMember]
public void JsZoomIn()
{
try
{
gantt.ZoomBySteps(1);
}
catch (Exception e)
{
MessageBox.Show("Zoom In does not work.");
}
}
This all works fine, but when I want to do things with the gantt that require Events, this is a problem. For example, if I want to print or fullscreen my gantt control. How can I do this?
In C# the code for this is:
private void fullScreen(object sender, RoutedEventArgs e)
{
Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen;
}
But what do I have to do in javascript to trigger this method? when the user clicks on the button fullscreen?

There would be no difference in calling this code from JavaScript compared to your previous example, except that the Silverlight plug-in imposes security restrictions for several things, including full-screen mode, print and file dialogs. These mean that these actions have to be initiated by the user clicking or typing something. Explained here at MSDN.
Therefore you cannot do this from JavaScript, even when the user presses a button outside of the Silverlight plugin - the user will have to click something within the Silverlight plugin, for example a button which raises an event which you handle in your C# code, and take an action directly.
In the case of full-screen, you will find if you are mixing HTML/JavaScript content with Silverlight that the Silverlight full-screen very likely does not at all do what you want - the Silverlight content will be full screen, and the HTML content will not be visible. You also can't use keyboard input (mostly). I'd recommend resizing the Silverlight object within the HTML page (possibly combined with maximising the browser window).

Related

Webbrowser Control - Dealing with popups that use javascript

after much research I've been trying to find a code that not only captures popup links in the webbrowser for it to navigate in, but also works on javascript codes that open new windows or popups.
i tried using the webbrowser1_newwindow event with the following code (and works great)
' prevent opening a new window
e.Cancel = True
WBAccountVirgin.Navigate(e.Url.ToString)
but it doesn't work with javascript code using:
javascript:newPopup
i managed to remove the javascript code as a string and just navigate to that and also works but not every time.
So here's the question:
What code can i use that works with every sort of newwindow event or popup where i don't need to provide the url beforehand of that popup? Also that works with javascript popup codes..
I've seen that most places people offer the solution of using the NewWindow2 and NewWindow3 event but that isn't even part of the pre-loaded Webbrowser control which i am using. I don't want to use the Microsoft Webbrowser that i have to import. I want to use the WebBrowser Control which is already loaded.

Touch events in JavaScript on Android

I have an HTML page with a div that acts like a momentary on-off switch. It works something like this:
$('#btn').mousedown(function() {
startAction()
})
$('#btn').mouseup(function() {
stopAction()
})
$('#btn').mouseout(function() {
stopAction()
})
This works fine in a regular web browser. But it doesn't work when I load up the page in a WebView under Android. According to this, mousedown events don't work on Android like most people expect them to; so, is there any other way to accomplish this? Basically, what I want is a notification when the user puts a finger down onto the widget, and when the finger is taken away.
I'd prefer to use JQuery, but I don't have to. I'd also prefer a solution that works on other mobile platforms.
If I remember correctly, on Android, the webviews have JS disabled by default and need to be enabled. You can enable them with the document at http://developer.android.com/resources/tutorials/views/hello-webview.html
I think really, you're up to the mercy of the device and the owner as to whether or not the user has javascript enabled.
http://hubpages.com/hub/How-to-enable-disable-JavaScript-on-the-Droid-Android-phone
Hope this helps
~Kevin

Browser tab close detect in gwt

I am developing a gwt application and I am going to support only for ie7. Now I have a requirement to detect browser tab close event.I have tried Window.addWindowClosingHandler(...) . But this is getting fired when we click any url in the page or refresh. I just want to detect only browser close event. I dont want to capture any other event like browser refresh, url click. Is there any way to detect only that.
it should work
Window.addCloseHandler(new CloseHandler<Window>() {
#Override
public void onClose(CloseEvent<Window> event) {
Window.alert("bye bye beautiful");
}
});
[EDIT]
or maybe you search onBrowserEvent(); and detect which event user do
public void onBrowserEvent(Event event)
{
switch (DOM.eventGetType(event))
Event.onClick
Event.onPaste
Event.onLoad
JavaScript doesn't expose what caused the page to get closed, so GWT unfortunately cannot expose this information.
The underlying JavaScript event is the onbeforeunload event.
You could use session cookies, as described in the selected answer of this question:
GWT WindowClosingHandler firing on Browser refresh too

Show window inside any web page

I want to implement a utility for myself that should provide a small console where I can execute random JS in any browser (much like Firebug's console - I don't reinvent the wheel, I just want to do something I need and just have fun doing it).
So the usage use-case would be this:
Click a bookmarklet from any browser.
It shows dialog (much like jQuery dialog or similar) with text area and couple of buttons.
User enter a JS in the text area.
User clicks a button and it gets executed.
User closes the dialog.
I don't know how I can display nice dialog on any web page (Gmail, news, static pages, whatever).
I think it would be possible to create a jQuery dialog (or other library) and show it on the page. But it could lead to a lot of issues as the dialog might conflict with page CSS, JS and so on.
So the question is how to display a custom dialog on any web page from all (major) browsers using JavaScript.
The NOTES: I don't want to have a popup window. IFRAME would be ok but we cannot use it as the web page's DOCTYPE might not support it.
Thanks,
Dmitriy.
http://getfirebug.com/lite.html
Works in IE, Opera, Safari - basically gives you firebug's functionality in any browser.
bookmarklets are pieces of JS code, so you can basically develop any kind of JS program and use it via bookmarklet... just do what you would do normally. check how other bookmarklets work.
regarding the window display - use lightbox-like effect (DIV layered over other content).

Embedded browser with iframe

I am writing a web application that will run in kiosk mode on a touch screen. I am currently only targeting it for running on Firefox 3. A few of the use cases I have need to visit external sites. I wish to do so with an embedded browser, which I'm tackling with the help of an <iframe>. I need back/forward buttons for the embedded home page.
I've managed to access the history object of the iframe with
var w = document.getElementById('embeddedBrowser').contentWindow;
w.history.back();
The history of the embedded window is the same as that of the parent window. Therefore for a newly loaded <iframe>, this call will go back to the previous page of the system.
Is there any way to avoid this or a more correct way of solving this?
Because there is only one history object shared within each tab this seems impossible. The proper way around it would be to test window.history.current or window.history.previous before calling back. Unfortunately, window.history.current is privileged and so not available to unsigned pages.
Here's a rough sketch of a messy workaround:
<iframe src="somepage.html" name="myframe"></iframe>
<p>Back</p>
<script type="text/javascript">
document.getElementById('backBtn').onclick = function () {
if (window.frames['myframe'].location.hash !== '#stopper') {
window.history.back();
}
// ... else hide the button?
return false; // pop event bubble
};
window.frames['myframe'].onload = function () {
this.location.hash = 'stopper';
};
</script>
Of course, this is assuming that no (#hash) browsing ever goes on in parent window, and so on, but it seems to work for the problem of limiting back movement.
You might want to take a look at Adobe AIR. It lets you write your application using all the same tools / languages (ajax, html, etc etc), but since it runs as a desktop app and not in a web browser, you have more control over things, such as embedding browser frames and knowing exactly what they are doing, what URL it's going to, controlling it's history, etc. Look here for a few pointers on getting started.

Categories

Resources