I am not able to include http://maps.googleapis.com/maps/api/js?sensor=false. Whenever I load my portlet for the first time it doesn't work but if I refresh the same page then it starts working fine. I don't know what the issue is. Please Help.
One of the clean ways to include js file in a portlet, independent of the portal server is to configure in portlet deployment descriptor file as below. For liferay, it would be liferay-portlet.xml.
<portlet>
<portlet-name>MySamplePortlet</portlet-name>
<header-portlet-javascript>http://maps.googleapis.com/maps/api/js?sensor=false</header-portlet-javascript>
</portlet>
Related
I am quite new to programing so I apologize for any blatant ignorance, but, I can't find this answer.
I am using window.open() to open a .php file in a popup and passing a variable within the URL for use with $_GET.
Everything works fine when the .php page file I am opening is located in my main directory, for example:
window.open("../filetoopen.php?link="+variable, ...)
But, when I move filetoopen into a different subfolder and change the path, the webpage will not load.
example:
window.open("../subfolder/filetoopen.php/link="+variable, ...)
Just as a side note, I am working on a web app that has been developed by multiple people over several years and have only just begun familiarizing myself with its inner workings.
Any insight/suggestions would be much appreciated.
I figured out the issue:
There was another .php file located in the root directory which was needed to be referenced for the page to load.
example:
include 'utils.php';
And, when I moved the file within the subfolder, I did not change the path of the other file as well.
example:
include '../utils.php';
Thank you for all your responses.
I am creating browser based video editing tool. I want a user to first download a ~70mb javascript file and store it somewhere on his computer. I want to link that file when my website is opened. How can I achieve that.
EDIT
What i meant is that there are various files like js1.js,js2.js... all sums upto 70mb . So i will offer a zip folder to download and only link js1 or js2 file etc depending on the effects user wish to apply
i am sorry to inform you but i think there is something really wrong with what you are trying to do.
A "solution" would be to just cache the javascript on the user's browser so any subsequent requests parse the cache instead of requesting the resource again from the server.
You should know however that if you are in need to download ~70mb of a javascript file you are doing something wrong. I have a whole web app project that when published the total size is around 60mb, all files required to properly run included, and its a damn big codebase in there.
I find it very hard to believe there is ever a need for a single javascript file to be that big, in any case maybe a simple caching should do the trick
That is actually done automatically. Once you add a <script> tag with a link to a local js file (also stored on the server) the file is loaded automatically.
See HTML <script> src Attribute for more information on that.
You can only reference to js files on the server. Files on the server could look like this:
index.html
somefancyjsfile.js
You can then reference from inside your html file to the js file via the <script> tag.
I'm not sure though if the size is not a bit too much...
This is my first time creating a mobile site for someone I have the javascript code all set up and when tested on my phone, it redirects it to: m.websitename.com, like I want it to. However, I have no idea what to name the file I am wanting it to redirect to? I saved the file under: mobile.html, but it isn't redirecting to it.
I don't want it to redirect saying www.websitename.com/mobile, I don't think it looks as professional.
Thanks
index.html or default.html is the convention. so why not direct to
m.websitename.com/index.html
and configure the subdomain so that m.websitename.com is actually pointing to websitename.com/m folder. so that folder can have its own index file.
You would probably want to do this using subdomain and destination setup from your server you are using (Most of webhosting companies made this easy through their software e.g. cPanel). Directory structures is going to look like this. So when user was redirected t m.yourweb.com/ then it's not going to have m.yourweb.com/mobie.
domain [directory]
css [directory]
js [directory]
index.jsp [file]
purchase.jsp [file]
...
subdomain [directory] <- for mobile
css [directory]
js [directory]
index.jsp [file]
purchase.jsp [file]
So when mobile user was detected, JS is going to redirect this user to the subdomain (for mobile) instead of normal directory.
The other recommendation (which is better I think) is use the same logic from the above but when user was redirected to m.yourweb.com/ load css file for mobile version web instead of normal web. loading css through JS
If you think this is complicated, you might be interested in having a look at CSS3 media queries. This basically changes CSS layout depending on current users' screen. resolution Media queries tutorial
You can have any filename you like. But as btevfik mentioned either put index.html or default.html
I recommend index.html
Also you can set the default file in you server configuration. By default most servers have the default file handler as index.html. For Apache it will be either index.html or index.php. You can change this to something like mobile-handler.html by changing the server configuration.
So whenever you access your site by http://your-site.com or m.your-site.com the default file specified in the server configuration is loaded.
Please note that your-site.com and m.your-site.com will have different site root, hence request will be handled by difffernt files.
I'm developing a Web Server for android and I've some problems with external javascript files (.js).
With an external css it works fine, because it receives the TCP of the css file and then the server send it as a normal file.
with javascript files it doesn't receive any GET/POST request.
Can I include any tag to tell the browser to get a js file?
at this moment I only tried this one: <script type="text/javascript" src="js/javascript.js"></script>
EDIT:
I just added "text/javascript" content-type but nothing seems to has changed. If I open directly http://ip/js/javascript.js I get the text of javascript.js. Then, if I came back on my index.html, all javascript functions work... why?
EDIT 2:
My server (at this moment) doesn't use threads.. for each request it send the page and restarts the connection. this may be the problem??
but, in this case it should works "something"... no?
EDIT 3:
I had a confirm that may be a thread problem:
if in html file I reverse the javascript and the CSS tag, javascript works, css doesn't work. What do you think?
Make sure you aren't caching the file on the client side. If you have the js file linked in the page it will always attempt to download it, with the exception of caching.
I was under the impression that if I deployed my application (using Ant) then JS files, along with HTML, CSS and images, would be automatically served by Tomcat.
However, after editing Javascript files I have to restart Tomcat in order for the changes to be updated.
My JS files are in a 'js' directory off of root (not in WEB-INF).
I am using FF3.6.
Any help?
I 've never worked with Tomcat but I find it hard to imagine it wouldn't serve changed JS files straight awayafter deployment. My guess is this is a caching issue on the browser's side. Can you try to force a refresh by opening the actual CSS file and pressing F5?
The usual approach to making sure a JS file gets updated is embedding it with a GET parameter that marks the version/revision:
<script type="text/javascript" src="/js/script.js?version=51"></script>
when you update the script's revision, and change the GET parameter, the browser should forget the cached version and re-load the file.
According to http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
cachingAllowed -
If the value of this flag is true, the cache for static resources will be used. If not specified, the default value of the flag is true.
I found out that Tomcat reload files from the /temp directory which was set by setting antiresourcelocking to true in the context xml's. Thanks guys.