.innerHTML does not work on Windows Phone browser - innerhtml

I have a problem with a label field on my HTML page. I have set a label as below:
<label id="labelid" class="required control-label">Old Label Value</label>
Based on some other form input, I am trying to change the value of the label using javascript. The code for that is:
function change()
{
document.getElementById(labelid).innerHTML = "New Label Value";
}
For some reason, this works fine on a desktop browser. It also works fine on IOS and Android phones. But when i view this HTML page on a windows phone browser, the new value is not visible.
Please advise. I must be doing something silly, but i cant figure it out.
The basic objective is to update a label based on what the user has typed in a text field. Please let me know if there is another way of doing it instead of using labels.

Try this code. You didn't have quotes around labelid..
function change() {
document.getElementById("labelid").innerHTML = "New Label Value";
}

In reference to Windows phone browser, Mark Chamberlain had these comments to a similar issue:
"Standard Javascript injection is not enabled; most likely due to risk of attacks, web site spoofing etc. If you need to customize a web site that you own, you should implement your changes on the web site (server) side."
This could possibly extend to adding/deleting/modifying HTML is my interpretation.
From this link: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/94d4a806-3eca-411e-adda-9e0fa8a6f467/how-to-inject-or-insert-the-javascript-code-in-webbrowser-windows-phone-7?forum=wpdevelop

Related

How to display a simple dialog in SharePoint 2010 without breaking the page?

I've worked on this for several hours today and am getting no where. Hoping someone can step in and please help.
All I want to do is display a simple message in a pop up dialog to tell users of some changes coming to a SharePoint 2010 site. I never thought this would be so difficult!
I've gone through a dozen links from a Google search but nothing has helped.
The only thing that sort of works is this code that I put into a Content Editor Web Part:
<script type="text/javascript">
function codeAddress() {
alert('ok');
var options = {
Title: "Survey",
height: 500
};
_spBodyOnLoadFunctionNames.push("codeAddress");
}
window.onload = codeAddress;
</script>
But, the problem with this code is that after I click Ok, the page behave strangely. The java script of the page does not work, and even editing the page is messed up until I delete the webpart with the code.
I suspect that the problem has to do with this:
_spBodyOnLoadFunctionNames.push
But if I remove it then the pop up does not work.
In case it's not clear, my goal is to show any type of dialog in which I can type a sentence or two to tell the user something. Then they can click OK and give full control back to the page.
Please please someone help!
Shame on Google for not leading you directly to SP.UI.Modal.Dialog.showModalDialog().
<script>
ExecuteOrDelayUntilScriptLoaded(showDialog,"sp.js");
function showDialog(){
var options = SP.UI.$create_DialogOptions();
options.title = "My Amazing Dialog Box";
// create a dummy HTML element for the body of your dialog box
var div = document.createElement("div");
div.appendChild(document.createTextNode("Some text inside my dialog box."));
options.html = div;
SP.UI.ModalDialog.showModalDialog(options);
}
</script>
If you want to put that in a content editor web part:
Save the above code into a text file
Upload that text file to a document library on your site
Add a content editor web part to the page where you want the dialog to appear
Edit the web part, opening up the web part properties panel on the side of the screen
Paste the URL of the text file that you uploaded into the "Content Link" property
This method prevents SharePoint from stripping your JavaScript out of the content editor web part, and lets you use that same script on multiple pages.

Does launchUriAsync work with .edu sites?

I've created a JavaScript Windows Store blank app, and added the following code into it.
var url = new Windows.Foundation.Uri("http://www.google.com")
Windows.System.Launcher.launchUriAsync(url);
when debugging my program the above launches google without fail, but if I put a .edu site or something that ends in .aspx, the site won't launch.
I'm not able to reproduce this. Perhaps there's something in how you're doing this that's causing the issue.
To try to repro, here's what I did.
Started with the JavaScript Blank app template.
Added a button to default.html, on the line following the <p> element: <input id="Button1" type="button" value="Launch" />
Added an event handler for the button in default.js, just after the call to WinJS.UI.ProcessAll: document.getElementById("Button1").addEventListener("click", launchUri);
Added the launchUri function, as follows, to default.js:
launchUri:
function launchUri() {
var uri = new Windows.Foundation.Uri("http://www.communitymegaphone.com/Default.aspx");
Windows.System.Launcher.launchUriAsync(uri);
}
Works fine for me, both with aspx (as shown above) as well as for .edu addresses.
If you're still not able to make it work, please post some additional code for context.
Hope that helps.
For more info on Windows Store app development, register for Generation App.

Where to put js code for polling tile notifications for windows8 js&html app

http://msdn.microsoft.com/en-us/library/windows/apps/hh761476.aspx
Those instructions are great, but where do I put the below code (grabbed from article above)? In my default.js file, above the app.addEventListener("activated", function (args) { line of code? Below that line? Elsewhere? Thanks Microsoft, but tell me where to put the code!
var notifications = Windows.UI.Notifications;
var recurrence = notifications.PeriodicUpdateRecurrence.hour;
var url = new Windows.Foundation.Uri("http://mytileprovider.com/tile.xml");
notifications.TileUpdateManager.createTileUpdaterForApplication().startPeriodicUpdate(url, recurrence);
Ideally this would just be a manifest setting with a dropdown of "Frequency" and an input box for the url to grab it from. That would be oh so helpful and convenient.
The answer is... it depends. :)
Where do you want to set up the tile and the polling? Is it an "always on" feature that is core to your application? If so, then put in inside the activated event for your default page (usually inside default.js). Or maybe you are adding tiles based on content that the user interacts with (i.e., selecting a stock to pin to the Start page). In that case, you would put that code inside the page that handles the user action that.
The simple answer is... inside the activated event. The real answer, as you can see, can be more involved.

display html in xaml

I wasted few hours for looking the answer and I'm very sad cause I didn't find anything usefull. I have a CMS in cloud and it provides content for diffrent devices like www site and my new windows store application.
I want to use html formating. I've already created app in c# and xaml and I'm wondering how can I display html
I was happy cause I found http://nuget.org/packages/RichTextBlock.Html2Xaml but I can't make it work. I get blank page. No text, no error, no nothing.
Can someone pls tell me how can I display html in my app ?
Use a WebView/WebViewBrush or use HTML Agility Pack and implement the styles/rendering yourself.
In WinRt app you can display html code by some ways:
Using WebView with it's NavigateToString("html content")
Using WebViewBrush and displaying it in rectangle
If you had your .html file local - you can open it with myWebview.Navigate(new Uri("ms-appx-web:///" + myPath));
You can make a screenshot of webpage by the method wich I describe here and open it as a picture.
For more info, see the WebView control sample

iPhone Web Application

I had a quick question regarding UIWebView. Is there anyway to programmatically navigate the UIWebView? Essentially, I prompt the user for certain information, such as (Current Location, Time). Using this information, I would like to fill out and complete a form on a webpage, and display the resulting UIWebView to the user. Is this possible?
You could use JavaScript to control the UIWebView using the stringByEvaluatingJavaScriptFromString method. For example you should be able to insert text into an input and submit a form:
NSString* script = #"document.getElementById('Name').value = 'Hello'; document.getElementsByTagName('form')[0].submit();";
[self.web stringByEvaluatingJavaScriptFromString:script];
You'd have to customize the JavaScript to do whatever you want. For example, you could inject values that you had collected into the script, then run the JavaScript.
You could hide the UIWebView until the new page had loaded, then show it to the user.
Come to think of it, it'd be nice if there were a Selenium type wrapper around the web view, but I don't know of anything like that right now.