I want to get client information via javascript. However I do not know which attributes are gotten by javascript. How should I learn this?
Have a look at window and document object properties. All client-side information is here.
you can use Navigator userAgent Property for that , as i understood you question
example Navigator userAgent Property
a very good reference for useragent
Related
I have come across a variable in javascript called window.sitedata but tried to search the details regarding it but unable to find.
Can some explain what is window.sitedata in java script ? what is its purpose, any documentation regarding it would be helpful.
I think window.sitedata is not available. Refer below link for window object properties.
https://www.w3schools.com/js/js_ex_browser.asp
FYI
https://developer.mozilla.org/en-US/docs/Web/API/Window
sitedata is a custom variable because the native window object does not have a property called sitedata.
You may ask (if possible) the programmer who developed the code.
Reference:
W3Schools
MDN
In our portlet, we are trying to access the language properties in our javascript files using Liferay.Language.get("key").
But Liferay.Language.get("key") returns the key instead of the associated value.
Did any one face similar issue?
We are using Liferay 6.1 EE. And have already seen the LPS-16513
The strangest part is it works on our local boxes but fails on server.
Any pointers other than using ext?
My best guess based on the information you give is that you're asking for a key that does not have a translation associated with it - for these returning the key is the default behaviour.
But then, this question is quite old, you might have already solved it. (If so, please let us know how - if you can remember the cause)
I also can't get it to retrieve a value for a valid key that's specified in a resource bundle in a portlet itself. It will retrieve values for keys in the default Liferay language bundles though. One hack is to add a liferay-hook.xml to your portlet and add something like the following to it:
<language-properties>Language.properties</language-properties>
When I do this it will now retrieve my custom/additional keys. The side effect is that your keys will also be available globally in Liferay.
This does not work for portlet level language.pro.
I have same problem with 6.2 EE too, as an alternative I went for below solution.
<script>
var test = "<liferay-ui:message key='test'/>";
console.log("This is working :: "+test)
</script>
Thank,
Sagar Vyas
You can also get the desired value with the following snippet:
var value='<%=LanguageUtil.get(pageContext, "key") %>';
I get it to send an email using javascript I use window.open('mailto:xxx') What I would like to avoid is opening a new browser window + opening an email window. Works fine except for that. I do my programming in CF. Is this possible?
Don't use "window.open()"
Either use an in your HTML,
or use location.href="mailto:XXX"; if it needs to be Javascript.
location.href="mailto://xxx";
Use location.assign():
location.assign('mailto:user#example.com');
While you can instead directly assign to location's properties (location.href='mailto:...';) to cause the browser to navigate, I recommend against this.
Internally, doing so is just calling location.assign() anyway, and assigning to properties does not always behave the same in all browsers.
Does anyone have a good solution for getting and setting variables in window.location.hash?
Take a URL that looks like this:
domain.com/#q=1&s=2
What I'd like is an unstressful way - JavaScript or jQuery - to check the values of q and s when the page loads, and change them following events on the page.
I have found some code for getting hash variables, but nothing sensible for setting them.
Am I missing something really obvious, or do I need to roll my own solution (and release it!)?
Thanks.
Haven't used it but there is jHash
jHash allows you to work with the
'location.hash' value in a similar
fashion to a server-side query string.
This library utilizes the HTML5
"onhashchange" event, but also
includes a fall back to still allow
the change notifications to work
properly in older web browsers.
jQuery BBQ can do this.
See also:
Get URL parameter with jQuery
Get QueryString values with jQuery
Edit as #gonchuki points out, jQuery.query can also do this.
JHash didn't work for me in that I wanted it to trigger the routes right away. I personally used routie instead.
It lets you do advanced routing just like jHash but will trigger on page load correctly.
Below will match example.com/#users/john
routie('users/:name', function(name) {
//name == 'bob';
});
According to this article Silverlight 2 Beta 2 supports the DataContractJsonSerializer object. But, when I try to use it VS says
"Type 'DataContractJsonSerializer' is not defined".
I have a method marked as ScriptableMember that gets called from JavaScript and is passed an Object. Inside this method I need to serialize the object to a string (preferably JSON) and then save it in isolated storage.
Does Silverlight 2 Beta 2 really support DataContractJsonSerializer? Or would anyone recommend a different method of saving the JavaScript created ScriptObject in the Isolated Storage?
Actually the answer is, the DataContractJsonSerializer is part of Silverlight 2 Beta 2, but you need to add a reference to System.ServiceModel.Web to your Silverlight project to use it.
I didn't realize that you still needed to add dll references in Silverlight. I thought it automatically included everything in a similar way to how ASP.NET does.
There is a Silverlight version of Json.NET that will serialize your objects to JSON. It doesn't require [DataContract] and [DataMember] attributes all over your objects.
Json.NET
For now, the only solution to this that I have found is to use the ASP.NET AJAX JavaScriptSerializer to do the JSON serialization/deserialization in JavaScript, and then just use Silverlight to store/retrieve the resulting string.
Sys.Serialization.JavaScriptSerializer.serialize(obj);
Sys.Serialization.JavaScriptSerializer.deserialize(json);
I would say your own answer would be the best approach. JavaScript is dead slow at doing stuff like that, so best you leave the serialization-part to ASP.NET.