I have an issue with my inline javascript which is in html page.
I'm using following code in the javascript.
ifrm.document.write('<link rel="stylesheet" type="text/css" href="file:///C:/Project-2/parent.css">');
This works perfectly fine on all the browsers, but not with Chrome.
Is there any workaround?
Thanks
Yes relative paths would be the way to go here. As of right now if you tried to deploy this page to the web then none of the links would work (assuming you're referencing files that reside on your PC via absolute paths).
Here is some good material explaining absolute vs. relative pathing: http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/
Related
The problem is that the slider on the home and products page only works with firefox chrome and Opera. It just fails to move in either IE or Safari. The second issue is about how the site scales on mobile devices. I've looked into mobile event handling, but with less than great results.
http://dextersaltmedia.net78.net/
Copy-pasting the entire responsiveslides.jquery.js file into the console makes the thing work normally, so your problem is in
<script type="text/javascript" src="responsiveslides.min.js"></script>
The only issue is that the library module never runs, even though the library gets included as a file.
Put your script tags at the end of the page, that might work better. Or try placing the library script tag at the end alone.
Ideally though, you should just bunch up jquery and the library file in one .js file and include that one.
My jquery image slider doesn't work on Macintosh at all. It works fine in Windows on all browsers. Can anyone tell me why? I'm very new to this. I believe everything for the slider is here. I can post the rest of my css if needed.
Could it be because you've specified images on a C: drive, which does not exist on the Mac? Can't you just use relative paths, and put the slider/images directory in the same directory as the rest of your project?
I'm building a website in local (using xampp). Every css stylesheet and js script is linked with a relative path. When I load the website here on my pc with chrome or any other broser I don't have any problem to see it.
I'm trying to see also hot the website appears on my smartphone and I already finded the tutorials to make it possible: i configured a new port and each time I need to reach the website thorugh the smartphone I just need to write something like 192.168.1.7:80/andtherestogthepathtoreachthewebsite
But I'm a problem: on smartphone the css stylesheets and js scripts are not loaded. And i discovered the reasons: because, for example, the css file style.css is loaded with this url http://localhost/../../../style.css while it should be http://192.168.1.7:80/../../../style.css: only in this way I could load on my smartphones all the files related to the website.
What I need is to change that first part of the url when the website is loaded through a mobile device. How can I do it?
Please, don't tell me "change the relative paths in absolute paths", I can't, the website is built with opencart, i can't change the relative paths.
I recommend you to use <base> tags, when you encounter these type of problems.
Syntax:
<base href='BASE_FOLDER_NAME'> // As per your question, BASE_FOLDER_NAME=andtherestogthepathtoreachthewebsite
So now you can link your CSS ans JS files without hassle,
<link href='css/style.css'>
<script src='js/script.js'></script>
How would I remove all links to javascript if someone is viewing a site from an iPad.
For Example the web version would have links in the head to js files for various things on the site.
But I would want the iPad version to remove or ignore these links so no js was being linked to.
Any help would be much appreciated, thanks.
You could load them on the client side, checking browser features, after page load.
They could also be written dynamically sever side by checking the user agent.
Detect the browser using this and write your code to make use of the isiPad variable. It would be easier to do than removing code tags from html (at least without jQuery).
i don't face this problem while working on localhost only when I access the page using the ip address of my system this happens and it only happens with IE!! (works on all other browsers)
by the way i'm using Tomcat V6.0.0.29, IE8
I tried debugging the JS code using IE developer tools debugger, ofcourse when I open using http://localhost:8080/ everything works perfectly fine, but when I use http://myIP:8080/ this loop is giving a problem :-
$('#someId > div').each(function(){...});
As in this loop doesn't run at all, it just kind of skips it. I have checked the IDs they are fine moreover its working in localhost why should it give a problem when I access it using my IP?
Note :-
a. (correction) The problem is only there in IE7, it works perfectly in IE8.
b. As it turns out something weird is happening! i'm using IE8 when i open this webpage using localhost the developer tools shows its working in IE8 standards but when i use the IP address to access this page the developer tools shows its working in IE7 standards. When i changed the standards to IE8 it worked (using the IP address)!
c. But the problem is why the hell is it not working with IE7!! As in everything works except the loop mentioned above.
Finally i came to know what was causing the problem in IE7. Consider the below situation:-
<div id="div1">abc
<div id="div2">def
<div>hjs</div>
<div>zyx</div>
</div>
<div id="div3">xsj
<div>ask</div>
<div>iue</div>
</div>
</div>
The jquery i had written for traversing these divs was something like
$("#divId > div").each(function(){..});
Now for the first level div that is traversing the divs directly inside the div with id "div1" worked perfectly in IE7, but when i did something like:-
$("#div2 > div").each(function(){..});
This worked in all browsers (even in IE8!!) but not in IE7. This is because apparently IE7 requires the exact child selector for divs.
So for IE7 something like this needs to be written:-
$("#div1 > #div2 > div").each(function(){..});
for traversing the divs inside the div with id "div2"
So the problem was cause just by my lack of knowledge about IE7!!
sorry n thanks guys!
The culprit being IE it could turn out something as evil as the browser not caching the page when loaded from localhost, but reading it from cache when using the ip. Make sure you load the page to empty cache from your ip.
Check to see if your script is loaded when using your IP address. Sometimes browsers don't load scripts on special situations (for example when you want to load a script from an http source into an https page). Also you should check IE's security configuration.
To check whether your script is loaded and executed or not, simply put an alert('loaded') statement at the beginning of your code.
This may due to the group policy of your company for forcing Intranet sites using a specific version of IE in compatibility mode. I experienced exactly the same issue when I introducing some IE10+ Javascript libraries to my page.
To work around this you can either ask your company IT for changing the policy or force the browser to not using a compatibility view with the following tag.
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
More details for this tag can be found with the topic below.
StackOverflow - Force IE compatibility mode off using tags