Re: Including a javascript relative to its own location from another javascript
- From: Nettar <jayaramanettar@xxxxxxxxx>
- Date: Thu, 20 Mar 2008 02:49:10 -0700 (PDT)
On Mar 19, 10:32 pm, Thomas 'PointedEars' Lahn <PointedE...@xxxxxx>
wrote:
Nettar wrote:
I want to include a javascript from another javascript.
I know that I can do that by
document.write("<script src='another.js'>");
You don't know. First, the required end tag is missing. Second,
document.write() after loading overwrites the document. Third, there is no
guarantee that the markup is included, let alone a guarantee that it is
included at a certain position. Fourth, if you were to include two scripts,
you would simply write the other `script' element instead of generating it
dynamically.
I am exposing my main.js (which contains the above code) directly,
intending it to be used via cross-site scripting (xss).
In this case, the above code doesn't work. Because an external html
which is using my main.js will look for another.js in its local
directory.
It will not work for the reasons I have given above instead.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Thanks for the reply.
1. All right, I missed </script> while writing the post. I have it in
my script.
2. My main.js is included in the html in the <head>. So it will be
executed before the document completes loading.
3. I didn't get your third point. Why isn't there a guarantee that the
markup is included? In my application it is correctly included.
4. I don't want to dynamically generate the another.js. It's content
is static. What I want to change is its location, and not content.
May be you didn't get my problem. I am able to include the another.js
using document.write(). But, I want to specify its location relative
to the location of main.js.
Can someone help me on this?
Regards
Jayarama Nettar
.
- References:
- Including a javascript relative to its own location from another javascript
- From: Nettar
- Re: Including a javascript relative to its own location from another javascript
- From: Thomas 'PointedEars' Lahn
- Including a javascript relative to its own location from another javascript
- Prev by Date: Re: make user only able to select 1 of 2 buttons?
- Next by Date: Re: make user only able to select 1 of 2 buttons?
- Previous by thread: Re: Including a javascript relative to its own location from another javascript
- Next by thread: Ajax call returning prematurily
- Index(es):