Chop Up A String To Obtain Just The Filename Of An Image
Feb 9, 2006
I need to chop up a string to obtain just the filename of an image. Lets say the image source is /images/thumbs/image.jpg. Using the DOM I have the source of the image in a variable called 'source'.
What I want to do is manipulate it so that it just returns the file name image.jpg. How can I achieve this? I tried split() to see if I could split it into an array using the / as a separator, but this didn't work.
I have recently come across the need for using the name of the image file within js, but I can't locate it. I am well versed in php, but my js skills are noticeably weak. About 25% of the way into the (partial) lightwindow.js I have placed a comment that shows where I need to access the current image filename.
Code:
This will stop image flickering in IE6 when elements with images are moved try
I want to submit a form but it requires a code that is generated by every session (not the php session type). What i'm looking for is for a piece of code that fetch the session code and set it as a variable that can be called in JS.
I know that exists in PHP the cURL that it's able to retrieve the code and set it but i don't know how to start...
I have spent the better part of a day trying to figure this out, but cannot get it to work. What I am trying to do it reverse the background color of a cell with the font color and vise-versa. However for some reason I cannot get JavaScript to obtain the current assigned value of a CSS style. Code:
I am working on a firefox extension. The job is to sit in the status bar and as I type into any form on any webpage, listen for keyboard events, then modify the key pressed by mapping it to some foreign unicode character and then sending it to the form in focus.
As I see it, there are two ways I can achieve it.
1) Capture the event, modify it and then send it and not be concerned with the form in focus.
2) Capture the event, prevent default action., find a unicode mapping for the key pressed, find the form in focus and based on the type of form, call a method to explicitly insert the mapped character at the cursor position.
Right now I am not able to find a way to do either. Once I get the focused element, I can do something to it. But I am not yet able to get that. I even tried document.activeElement, but it doesnt seem to work in firefox.
I know this is possible to get data from a specific cell in a table on your site :
But is there any way to replace 'document' whit an external url so you can obtain data from a specific cell in a table on another webpage. Maybe like this (I know this isn't even close to be able to work...):
I'm actually not sure if this is even possible whit javascript. If not, do you know any php script whish does that job?
<script type="text/vbscript"> Dim objWord Sub Btn1_onclick() call OpenDoc("K:DeloitteTeam1 Status reportJavaProgramshi.txt") End Sub
Sub OpenDoc(strLocation)
Set objWord = CreateObject("Word.Application") objWord.Visible = true objWord.Documents.Open strLocation End Sub </script>
I would like to pass the filename used above in the button code below so the above code could be coded only once and then mutiple button code could be used.
Can I subtract the filename form the location.pathname ex: Before = 'file:///c:/afolder/awebsite.html' After = 'file:///c:/afolder/' Or is there any other way to get the directory without the name of the file being veiwed?
Is it possible to get the Server IP Address from Javascript
ie., when the user types "http://10.0.0.10/main.htm" in the web browser, i need to retrive the value of the IP Address(10.0.0.10) from my client side javascript.
I have a textfield and you of course you can select text...
When they hit the bold button I want it to obtain the selected text and bold it, the hard part is trying to figure out if javascript can even OBTAIN selected text?!?!
I can do this in java if I have to, I know java better than javascript, it seems as that is the only way to do it from looking online.
Prototype seems to have a keys method which would achieve what i'm looking for. There are also a few pages which attempt to address the issue with JQuery, such as: [URL] However i was only able to retrieve the numerical index of the array elements using these methods (vs their name).
How can I obtain content of cascade style, using javascript? I know, there's a code document.getElementById('id').style.border='5px solid blue'; For example, but I need to do reversed operation, not to change style, but obtain it.
Is there a way to obtain the DIV you are currently hovering over using Jscript?
Basically I have ten thumbnails that I'd like to change the borderColor for using onmouseover. Instead of having to specifically create a DIV for each thumbnail (#tmb1, #tmb2, etc.) and then having to attach a separate function to each one (document.getElementById("tmb1").style.borderColor = "#660000") I'd like to be able to detect the DIV the mouse is currently over and change the borderColor of that.
I have over thirty pages, each with 10-15 thumbnails, which is why I'm trying to come up with something more generic.
This is a simple script I though of to get the filename of container for html.
Note: this only is tested on mozilla firefox 2 on windows vista
document.write("<a style='display:none' id='zFilenameFinder1' href=''>q</a>"); document.write("<a style='display:none' id='zFilenameFinder2' href='b'>q</a>"); var zDocURL = document.getElementById('zFilenameFinder1').href; var zCompareURL = document.getElementById('zFilenameFinder2').href; zCompareURL = zCompareURL.replace('b',''); var zFilename = zDocURL.replace(zCompareURL, ''); alert(zFilename)//filename handler
it works by creating two relative urls. one's href is blank, which when called by link.href returns the absolute value, giving the absolute link the page, then you compare it to a link that has a relative href of "b" which can be compared to the other link to give you the whole url
Is there a way to set the cookie filename with JS?
Currently it is setting it as 'asp/' (my directory). Can i specify it? This is my code:
function setCookie(NameOfCookie, value, expiredays) { // Three variables are used to set the new cookie. // The name of the cookie, the value to be stored, // and finally the number of days until the cookie expires. // The first lines in the function convert // the number of days to a valid date.
var ExpireDate = new Date (); ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
// The next line stores the cookie, simply by assigning // the values to the "document.cookie" object. // Note the date is converted to Greenwich Mean time using // the "toGMTstring()" function.
I'm trying to figure out a way to pass the filename before submission... I think I have to make an onChange command on the file field, but not sure how...
This is what I have done so far: <script type="text/javascript"> function theimage(){ var imgURL = document.getElementById('myfile').value; ste.execCommand("insertimage", imgURL); } </script>
I want the client to be able to obtain the http headers for a website I have. Mainly the WWW-Authenticate information (http digest). None of the scripts online have this. Someone said that on the server side I'd have to generate the code for the client, but how would I go about doing this?
I'm using Joomla. I've got a dropdown which reads the filename from the database. When the user selects it I want an onchange event to open the pdf.I've been at it for 2 days now.
<?php $con = mysql_connect('localhost', 'root', ''); if (!$con)
how to save form values in cookies, etc. for use when re-displaying the forms. for example, after an error has been detected. Naturally, PHP allows you to do this with $_SESSION variables.
But no one seems to have cracked the problem with FORMs having file uploads. Browsers will send the file to the server and the name, but not the path on the client computer (I suppose for security reasons).
So, if you want to re-display the page, you can fill in all the form data in your PHP script so that the user doesn't have to re-enter everything. But, since your PHP script only knows the NAME of the uploaded file, and not the path, whatever your fill in for the "xxx" in <input type="file" value="xxx" /> will be wrong.
I have a webform that creates a word document as it's ouput (yes I know it only works on IE). function createWordDoc(){ Doctxt = "some text here" var w=new ActiveXObject("Word.Application"); w.Visible=true; w.Documents.Add(); w.Selection.Font.Name="Times New Roman"; w.Selection.ParagraphFormat.Alignment = 1; w.Selection.TypeText(Doctxt); w.Documents.Save(); }
My issue is with saving the file. At the moment, in the above code, it opens the save dialogue box, and populates the filename field with the first line of text in the document. What I want to be able to do is populate the filename field with a variable filename created by the function. I've tried the snippet below, which works with the dynamic filename, but it autosaves the file to "My Documents" folder without prompting. I need to be able to allow the location to be changed. var FileName = "Myfile.doc" w.ActiveDocument.SaveAs(FileName);
I'm working on an internal website at work and employees have a cookie created when they login to the customer support tool. The filename is cookie:username@domain.com/ and I'd like to use javascript to pull a variable for their username to plug into a URL for a unique link when they're viewing one of our intranet pages.
@domain.com/ will always be the same but I don't know how to pull the unique username from the filename of the cookie. I don't need to actually read the cookie.