My situation is the following:
I have an index.html and some JavaScript that loads HTML snippets from the server. Inside these snippets, I have some URLs to images like
/some/folder/picture.jpg
Of course these do not work in PhoneGap. Weinre tells me that PhoneGap is trying to load the picture from
file:///some/folder/picture.jpg
Any ideas how to solve this? I was thinking about something like a base href, or some configuration in PhoneGap where one could specify a root path, but I did not find anything like that ...
Thanks,
Michael
I had the same problem especially when you have a lot of views (pages) and want to load one from a menu, yet you are at an unknown location.
The simple work around is to use the window.location object.
window.location.href.split('www')[0] + 'www'
This gives you the absolute URL to your 'base'. The www is the folder which is relevant for IOS and Android, so this also makes your app compatible in multiple platforms.
From this you can use a regular expression which passes the entire doc like jquery mobile does with data-* attributes to describe their elements. You simply replace the regular expression with the path returned. You'll want to do this during initialisation otherwise it will create a massive bottle neck.
Hope this helps and is along the lines of what you're looking for.
Cheers,
Sententia
You can't do that with a <base> because / is always host-relative — it can't be redefined to be in a subdirectory. You have two options:
rewrite your HTML to use fully relative paths like ../../some/folder/picture.jpg (or have something do the rewrite for you as a build step), or
alter the "browser" (PhoneGap's wrapper) so that it loads URLs differently.
I'm not familiar with PhoneGap so I can't comment on automatic options, but I personally would start using relative URLs.
Related
I hope someone here has used the Blink.jl package for building Julia and Electron apps.
I am having problems setting up and using it, though. The issue is with all of the functions in the api provided: load/loadcss/loadjs/importhtml. They do not seem to work, or I might be doing something wrong.
For example:
loadcss!(w, "styles.css")
does not apply any of the styles in the styles files in the directory.
importhtml!(w, 'index.html')
does not display the html page stored in the local directory. The app shows a blank screen.
I might be doing something wrong as i could not find documentation on how to use the package
I think I found out why, the methods take the full path and not the relative paths, even if files are inside the same folder. So, something like this works:
loadcss!(w, "D:\project\styles.css")
but this won't work:
loadcss!(w, "styles.css")
Why do relative paths not work in popular basic Content Management Systems which use "editable" class tagging? It's weird that every time I edit a page in the CMS all my styles and jS are killed because of my relative paths. What's going on behind the scenes? Are they making a duplicate copy of my page? Although that still doesn't seem to quite explain it, because forward relative paths such as
/css/style.css will still work,
but relative paths going backward such as
../css/style.css
will no longer work.
Even if they make a duplicate copy, they have FTP access and it seems like they should be able to trace relative paths... Instead they need an absolute or root-relative path.
Relative paths work fine in Surreal, but if your page has include files then the paths may "break" depending on where the page that's including it is located.
Regardless, you can adjust URL formatting pretty easily in Surreal:
<div class="editable" data-urls="absolute">
...
</div>
More details are in the docs: http://www.surrealcms.dev/docs/url-formatting
I'm developing a Firefox extension using AngularJS and I'm trying to use some of the AngularJS services inside my main.js file. I use require() to include the relevant modules and angular.bootstrap() to initialize the modules.
However, I always get the following error:
Reference Error: window is not defined
Is there anything else I can do about it?
AngularJS isn't really meant for this kind of environment - it is an MVC framework and in your case V (the view) is missing. You don't tell what you want to use AngularJS for but you might want to consider using it in your content scripts rather than main.js.
That said, AngularJS is often using window simply as a means to access the global object. This is easy enough to fix, the next-to-last line of AngularJS source code says:
})(window, document);
This should be changed into:
})(this, document);
This will at least allow the functions to proceed that don't really require a view. Of course you would still need to remove the last line (the one attempting to insert a stylesheet into the document) and export the angular variable instead:
exports.angular = angular;
There isn't much detail so I am unsure if this suggestion fits with what you want to do. If you want to use some JS libraries that require a DOM and don't want to show a document to the user, consider using the page-worker module:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/addon-kit/page-worker.html
You will need to set up event-driven communications between the worker and main.js, as with any other content document used with SDK code:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/guides/events.html
May be you have to get window object via
var window = require("window-utils").activeBrowserWindow;?
What is the view that you are trying to update? You should be able to provide angular.bootstrap with some non-root element to start compiling from. http://docs.angularjs.org/api/angular.bootstrap
If you're using some service that relies on window, you also might need to supply your own tweaked $window service. http://docs.angularjs.org/api/ng.$window
I am using grails 2.0.1 and i tried linking to the html page using with the direct url="somefile.html> but it is not working out . How do i do it ?please help
You need to do two things:
Make sure the file is stored under web-app/somefile.html, this is where you store raw files for the server.
Instead of using a hard-coded URL, use the g.resource() method or the <g:resource> tag. In these cases, you'll use it like so:
My Link
The reason to use the g.resource tag is it guarantees a correct link to the file. If you just hard code the file like href="somefile.html", then is is a relative path. If you are at the URI myapp/controller/action/foo, it will look for the file under myapp/controller/action/somefile.html.
Note: If you are using the cached-resources plugin or something similar, you will find the output URL is not actually myapp/somefile.html. The file is still accessible from that location, but the generated links will point to a static URL instead.
I'm modifying a website made with osCommerce (I didn't make this website), and one of the things I have to modify is the look of the home page. My problem is that I have modified the index.php file, and all the changes look fine.
However, when I click a link that has been written in PHP with this function:
<?php echo tep_href_link(FILENAME_DEFAULT,'cPath=24&sort=2a') ?>
(In /includes/filenames.php I have define('FILENAME_DEFAULT', 'index.php');.)
What happens is that it shows the correct results, but in a different page, with the old design. I don't understand it, because that link should take me to the same index.php that I modified, but obviously it's taking me somewhere else.
I don't know what page is it showing, the only thing I see is the link written by the PHP function:
(my_catalog_folder)/escaparate-c-24.html?sort=2a&osCsid=p7fp55t489nv042p0ip4mp7si1
I guess that the tep_href_link() is writing that, but I don't know what page is using to show the results.
Any clues would be much appreciated!
This is expected behaviour if the store has the SEO URLs module installed.
Look in the .htaccess file and you should spot this line:
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
Any and all requests for a category will be rewritten in a friendlier URL string like the one you noted.
As to the use of the older design, double-check the real file being called with an echo out of the $_SERVER["PHP_SELF"]; or $_SERVER["SCRIPT_NAME"]; and make sure the filename and path is correct.
Drop that into a file like includes/application_top.php before the final lines (or the closing ?> if you still have that there):
echo $_SERVER["SCRIPT_NAME"];
It may also be due to caching of the pages. Check to see if there a cache module installed as well.