Hi,
I have a script for a CMS that preloads an image by setting the SRC
attribute. The problem is that the location of the image as seens from
the final HTML page depends on whether the CMS has search engine
friendly (SEF) url's urned on.
If it is not on, the location is just the normal absolute location of
the image, and it is then easy to fetch it.
However, if SEF is on, the location could be anything. Pre-loading the
image will then usually fail because the url deduced by the script would
be wrong.
But the image is located relatively to the script itself, so if the
script could just determine "where I am" it would be a piece of cake to
get the address of the image!
But is it possible for a script to determine its own location?
Regards,
Martin 5 5193
On May 21, 12:29 pm, Martin Larsen <martin+spamfre e
+lar...@bigfoot .comwrote:
Hi,
I have a script for a CMS that preloads an image by setting the SRC
attribute. The problem is that the location of the image as seens from
the final HTML page depends on whether the CMS has search engine
friendly (SEF) url's urned on.
If it is not on, the location is just the normal absolute location of
the image, and it is then easy to fetch it.
However, if SEF is on, the location could be anything. Pre-loading the
image will then usually fail because the url deduced by the script would
be wrong.
But the image is located relatively to the script itself, so if the
script could just determine "where I am" it would be a piece of cake to
get the address of the image!
But is it possible for a script to determine its own location?
If it's a single script with absolute path in src attribute then maybe
var myURL = document.script s[0].src;
I did not test it on practice.
On May 21, 6:29 pm, Martin Larsen <martin+spamfre e+lar...@bigfoo t.com>
wrote:
Hi,
I have a script for a CMS that preloads an image by setting the SRC
attribute. The problem is that the location of the image as seens from
the final HTML page depends on whether the CMS has search engine
friendly (SEF) url's urned on.
If it is not on, the location is just the normal absolute location of
the image, and it is then easy to fetch it.
However, if SEF is on, the location could be anything. Pre-loading the
image will then usually fail because the url deduced by the script would
be wrong.
But the image is located relatively to the script itself, so if the
script could just determine "where I am" it would be a piece of cake to
get the address of the image!
But is it possible for a script to determine its own location?
Once the document is loaded, you can reliably get all the script
elements using getElementsByTa gName. You can sift through them,
looking for an attribute value that suits. If you want valid HTML,
add a search string to the src attribute and look for that e.g.
<script src="blah.js?xx >...</script>
If you don't want to do that and validity isn't an issue, give it a
custom attribute and use getAttribute().
--
Rob
On May 21, 1:37 pm, RobG <r...@iinet.net .auwrote:
Once the document is loaded, you can reliably get all the script
elements using getElementsByTa gName. You can sift through them,
looking for an attribute value that suits. If you want valid HTML,
add a search string to the src attribute and look for that e.g.
<script src="blah.js?xx >...</script>
getElementsByTa gName works! Thanks :)
But I don't understand what I would need the search string for? Would
it not be enough to look at the script name itself?
Regards,
Martin
On May 22, 8:25 am, marlar <marlar...@gmai l.comwrote:
On May 21, 1:37 pm, RobG <r...@iinet.net .auwrote:
Once the document is loaded, you can reliably get all the script
elements using getElementsByTa gName. You can sift through them,
looking for an attribute value that suits. If you want valid HTML,
add a search string to the src attribute and look for that e.g.
<script src="blah.js?xx >...</script>
getElementsByTa gName works! Thanks :)
But I don't understand what I would need the search string for? Would
it not be enough to look at the script name itself?
I guess so, but your script may not know what the filename is, or you
may want to change it to whatever you want and just have the server
add the search string when it builds the page. Also, you might have
more than one script with the same name but different path, and so
on. I just figured it might give more flexibility.
--
Rob
On May 22, 4:55 am, RobG <r...@iinet.net .auwrote:
Also, you might have
more than one script with the same name but different path, and so
on. I just figured it might give more flexibility.
You are right about this. The search string would make it safer.
Martin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew V. Romero |
last post by:
First off, I am mostly familier with PHP but am trying to make a
multi-step javascript program. For an example, I would like to run
different sections of the script depending on how many times the user
presses the submit button:
<form method="post" name="step1" action="test.html">
<script language="JavaScript">
var position
|
by: Mike A |
last post by:
Hi,
I'm hoping someone can help me with this.
I have a URL for which I'd like to limit access to by time. For
example,say I have a URL that I don't want accessable on Monday mornings
between 10am-noon and Fri. afternoons between 2-4pm. So when someone clicks
on the URL during those times a message pops up saying somthing like "sorry we're
closed now etc"
Is this possible? if yes, I'm guessing I'll need somesort of "onclick" for the
|
by: Nymphetamine |
last post by:
<script language="JavaScript">
if (parent.frames.length==0) {
location.href = ""
}
</script
I use the above script to redirect websites but is there any script
that can hide the new url? or do I have to pay redirection.net?
|
by: Karl Burrows |
last post by:
Here's a simple script I have pulled from various sources and wondered if
there was a way to improve it. First, if the type the wrong password, I
would like to redirect them to another login page to tell them to try again.
Second, I would like to figure otu a way to keep someone from just
bookmarking pages behind the main page to bypass the password. I know this
is nor perfect and there is nothing critical behind the password protected...
|
by: Joker7 |
last post by:
Hi,
This is still giving me a big problem !!
Maybe if I post the original code here it may be of more help as the above
will/is not working.
$link = "<a
| |
by: pdc |
last post by:
I have two web servers that I use, one is the primary and the other is a
backup for when the server is down.
I use a third, central server which redirects a browser's initial link to
one of my web servers.
Rather than getting involved with CGI to determine the status of the web
servers, I found and implemented the following javascript.
<!- this is a very simple page that uses javascript to detect
whether or not a gif file can be...
|
by: pdc |
last post by:
have two web servers that I use, one is the primary and the other is a
backup for when the server is down.
I use a third, central server which redirects a browser's initial link to
one of my web servers.
Rather than getting involved with CGI to determine the status of the web
servers, I found and implemented the following javascript.
<!- this is a very simple page that uses javascript to detect
whether or not a gif file can be obtained...
|
by: petermichaux |
last post by:
Hi,
I'm hoping for a reason I'm wrong or an alternate solution...
I'd like to be able to dynamically include some javascript files. This
is like scriptaculous.js library but their solution is broken in
Firefox 1.5.0.1 on OS X. What happens with the Scriptaculous library is
this
In the html document the author only has to include one line
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |