Relative Paths To External Files
Oct 12, 2011
I have a simple php webpage that links to an external javascript file:
But I want to avoid this:
I've seen so much on the web for Ajaz, ASPX etc. and it all looks a little confusing.
Using ../php/myphp.php works well for php files, what's the way to do it with javascript?
View 9 Replies
ADVERTISEMENT
Dec 11, 2005
The two pages for preloading below seemed to preload images IF I used an absolute path but they don't preload the images if I just used relative paths like the ones below.
Give it a try. The two pages below using relative paths won't work. Then try changing the paths of the images in both pages to use absolute path(with http://) which will work.
But I want to use relative paths. What can be done? Other than inserting 1x1 size of the images I want to preload. Code:
View 1 Replies
View Related
Nov 25, 2009
First the code:
Code:
Looking at the code, you might assume (as I did) that clicking the button on page1.htm would load page2.htm. However for some reason, when calling a parent function, the function runs with the calling file's path rather than the path of the parent.
So it is actually trying to load /files/files/page2.htm! How do I force all calls to parent.function() to run with parent.hta's path as the root?
Realize that this is a simplistic example and simple solutions such as putting all the files in the same path, or dropping the "/files" in the loadPage2() function are not valid solutions.
Essentially I need to call parent.loadPage2() and have it run the function with the root path = parent.hta's path.
View 3 Replies
View Related
Oct 2, 2010
I have the following JavaScript (see below). The script requests an XML file from the server and displays it on the page.The script works fine when the requested XML file is stored on the same server as the script.The problem is when I try requesting an XML file from an external server such as the National Weather Service. I get an error. If I take the XML file from the National Weather Service and save it to my server it works. Why can't I use my script to request XML files stored on external servers?
Javascript Code
Code:
window.onload = initAll;
var xhr = false;
function initAll() {
document.getElementById("makeTextRequest").onclick = getNewFile;
[code]....
View 6 Replies
View Related
Feb 18, 2011
I'm writing a JS script that will be available as open source. This script needs some accompanying image files. I have been planning to package the .js and the image files together in a single directory and let the user put that directory anywhere they want. Trouble is, I can't figure out how to write JS code to put a reference to these image files into the html. The image files are relative to the .js file, but I haven't seen anyway to figure out the path to the .js file (i.e. the path to the code I am now running). Is there a way? If not, how do people usually package up a .js file and some accompanying image files?
View 11 Replies
View Related
Jul 20, 2005
Is there anyway to pass a value to the external file?
example
<script src="http://www.thesite/js/today.js?something=1">
</script>
View 1 Replies
View Related
Dec 18, 2011
I've tried looking at various online sources but they are all either too technical or don't seem to work. I'm obviously doing something wrong!The code is posted below, it's not very long so hopefully someone will be able to debug it!Original page:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
[code]....
View 4 Replies
View Related
Sep 2, 2007
<body>
<iframe name="alertiframe" id="alertiframe" width="1" height="1" src='xmlsample.html'></iframe>
<script>
function alertfunc()
{
sometext = window.frames['alertiframe'].document.all.tags['to'][0].innerHTML;
alert(sometext);
}
</script>
<a href="javascript:alertfunc()">Click Me</a>
I am working with an older browser more of MAC IE. It works with DOM 1 and extremely partially with DOM 2. contentDocument and contentWindow does not work on this browser.
The above code works very nicely, however as soon as I rename the file to "xmlsample.xml" with an xml extension, it does not work anywork. If you have any other solutions please let me know. Rem we can't use any newer techniques, this is very basic DOM.
View 4 Replies
View Related
May 19, 2001
I have a question related to calling external JS files.
I have the following code in a .JS file:
document.writeln('<a href="http://www.xyz.com" TARGET="_BLANK" TITLE="For an online directory of distance graduate programs, click here!"> Click here!</a>');
It works perfectly...
I would like to add a mouseover command to it, i.e.:
onMouseOver="window.status='Click here now to visit Education.com!'return true" OnMouseOut="window.status=''return true"
I've used the correct slashes in the right places. However, it doesn't work; probably because I'm trying to place Javascript within Javascript. How can I place the onMouseOver command in the code at the top of this page?
View 3 Replies
View Related
Jan 8, 2006
Having very minimal knowledge of JavaScript, I am curious if there is a difference between external JS and JS inserted into the head of the HTML file?
I chopped out some JS for a menu from the HEAD of an XHTML document and put it an external JS called menu.js. The script follows. Code:
View 4 Replies
View Related
Feb 22, 2006
I am working on JS navigation for my web page. Contents of 3 subpages
are located in the array as shown below. When certain key is pressed on
the page, div is filled with data taken from one of the array rows.
***
var content=new Array()
content[1]='<p>some text</p>'
content[2]='<p>some other text</p>'
content[3]='<p>yet another text</p>'
***
The question is: is it possible in some simple way to put the data from
those 3 rows into 3 separate files and make the JS code to take the data
from those files? (I want to have 3 files with plain HTML) If so, please
show me some example how to do that. Or give me some address where I can
read about it, please. I have been using Google for several hours -
unfortunately without any luck.
In general - here is what I would like to do:
***
var content=new Array()
content[1]=[contents of Ƈ.html' file]
content[2]=[contents of ƈ.html' file]
content[3]=[contents of Ɖ.html' file]
***
How can I put the above into JS code?
View 3 Replies
View Related
Sep 2, 2009
I have a file links .js. In it i have this code
Javascript Document
On another page, hazards.html i use this code to call that function
But it doesnt display, nothing does. What am i doing wrong?
View 1 Replies
View Related
Jun 4, 2009
I have an advertising script , its embedded on the html page . here is the code from the HTML
Code:
<script type='text/javascript'><!--//<![CDATA[
var m3_u = (location.protocol=='https:'?'Linkhere':'Linkhere');
var m3_r = Math.floor(Math.random()*99999999999);
[Code]....
View 1 Replies
View Related
Aug 22, 2002
I have a dynamic (PHP) external JavaScript file. I need to load that file every X seconds and execute its contents, given the the page is already 'Done' (fully downloaded).
How can this be done?
View 6 Replies
View Related
Nov 11, 2011
So right now I'm able to execute javascript code on my website without the use of <script> tags. Example: <body onload=alert("cool");></body>
What I want to be able to do is insert an external javascript file located at another website using JavaScript code (not script tags). How can this be done?
View 21 Replies
View Related
Apr 14, 2006
I have been struggling with a cross browser solution to loading
external javascript files on the fly.
I have been successful using the following code in IE6:
var newScr = document.createElement("SCRIPT");
newScr.src = "newScr.js";
newScr.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(newScr);
I believe the reason is that IE is loading the external file
syncronously while Firefox is not. Is there an onload event for
creating an element (if so I do not see it in Venkman). I have seen the
solution of using XMLHTTP to load the script but I am trying to get
around any dependency (atleast at this stage of the library) on
activex.
View 1 Replies
View Related
Aug 21, 2006
1. I create an HTML document that validates at w3c
2. I use:
<script language="JavaScript" type="text/javascript"
src="dashboard.js" ></script>
3. <body onload="something_in_dashboard_js()">
4. In Firefox, it works beautifully ( no shock )
5. In IE it does not ( no shock )
6. If i put the function in inline <scripttags in my HTML, the JS
runs fine (no syntax error).
View 5 Replies
View Related
Aug 25, 2009
I built a small JavaScript file that does some HTML and CSS manipulation when you hover over any tag with a certain class. It works great when running on the same server, but if I try to use the JS as an external script, the hover event isn't triggering. Here is my external JS file code:
$(document).ready(function() {
alert('i work inside');
$(".start").hover(
function (e) {
[code]....
View 4 Replies
View Related
Oct 24, 2011
I am using a 3 column layout. One column contains links and 2 columns contain content. I need to load the content to 2 Divs in one click. When a link is clicked it should load some file in column 2 and another file in column 3.
As of now I am loading only one div using jquery load function. But I need to load 2 divs. Below is the code Ib am using.
Or is there any other option to load 2 external files in 2 different div in one click
Example
Head
<script type="text/javascript">
$(document).ready(function(){
$('a.menu_links
[Code]....
View 2 Replies
View Related
Oct 15, 2007
I need a way of loading api scripts on the fly. ie. if the user clicks on a link the javascript would suck in the api script depending on what the user has selected. By api script I mean:
<script src="http://api.maptp.map24.com/ajax?appkey=blahblahblahthisisakey" type="text/javascript"></script>
I am using the maps24 api to build an address finder - ie. put your postcode/zipcode in and populate the rest of the address details. For some reason you need to load a different js file for each region (north america, europe, etc). I want my users to click on their region and have the <script> tags inserted into the head. I have done this using javascript but the functions don't seem to be available. I am assuming that the page needs to refresh??
Does anyone know away of making the javascript functions available to use without having to refresh the page? In other words, loading javascript files on the fly.
View 16 Replies
View Related
Oct 25, 2010
I am implementing Ajax for a new website and I've run into a hurdle.
It seems like Javascript does not 'see' any div elements that are loaded from external file with Ajax.
Is this a common issue, and is there a solution? Or am I overlooking something obvious?
What I'm doing is loading a simple external page via Ajax. The pages loads just fine, and it contains div's with unique id's. If I execute a Javascript function, it seems to not recognize these newly-rendered div's from the Ajax external file. Is this the case? Can Javascript be re-invoked on command, so it can see the new div's?
View 1 Replies
View Related
Jul 20, 2005
I have a problem of client side XSL transformation. I sent the XML and the XSL to the client in XML data islands. Using the transform Node method the HTML is returned. There
is however some script tag in the XSL file which references external
..js files they are like
<SCRIPT language="Javascript" src="abc.js" DEFER="true" />
Now, after transformation the function from this .js file are not
called and object required errors are thrown. This is despite the fact
that IE has downloaded the .js file and they are visisble in the cache
(Temporary Internet Files). This problem only occurs if the .js file
is not present in the cache, hence it happens when the user visits
some site for the first time.
View 1 Replies
View Related
May 8, 2010
View source code of external files in html like *.js and *.css
For example:
In this page I am Posting to, there are 24 *.js files. They are loaded but you can't see them. I would like to view some of these external javascript files for study. Not necessarily on this site, but where ever I find them.
View 1 Replies
View Related
Mar 14, 2011
This is my first message and I am extremely new to jQuery. I am using Ajax to call external html pages into a div in my site. I have three external html forms which uses JavaScript and one .file. When I call these pages, the html pages are being rendered correctly but the JavaScript and .pl file (form post) is not being executed. Any ideas on how to resolve?
View 1 Replies
View Related
Jul 23, 2005
I am setting a cookie on a subdomain:
http://store1.mydomain.com
Then the store takes me to a shopping cart that is at:
http://shopping.mydomain.com
Somewhere the following code (taken and modified from The JavaScript Source)
is broken between domains, because when I click my "store" link that should
read the cookie and send me to store1.mydomain.com or storeN.mydomain.com I
get the default template store.
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ronnie T. Moore -->
<!-- Web Site: The JavaScript Source -->
<!-- Begin
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var favorite = GetCookie('store');
if (favorite != null) {
switch (favorite) {
case 'store1' : url = 'http://store1.mydomain.com/'
break;
case 'store2' : url = 'http://store2.mydomain.com/'
break;
case 'store3' : url ='http://store3.mydomain.com/'
break;
case 'storeN' : url = 'http://storeN.mydomain.com/'
break;
}
window.location.href = url;
}
// End -->
</script>
</HEAD>
The cookie is set by a javascript "onload command" Like I said I have it
working on a server with no sub domain.
View 1 Replies
View Related
Jul 9, 2010
My page accepts a url with various parameters passed in querystring. One of the parameter is the URL of the Image I wish to display on the page. I save this URL in a variable "imagesource"
To ensure the image is not bigger than the size permitted, I use image object to get the height and width of the image.
Now here's my code:
function foo(){
......
var imagesource = URL of the image;
....
var newImg = new Image();
[Code]....
View 4 Replies
View Related