So I have to make a button that changes an image that I have (which I then have to be able to change back to the previous image with a click of the same button). However the image when it changes doesn't show.
Here's the code, if it's not well put in keep in mind this is my first using this site.
//FUNCTIONS
function changerPingouin(pingouin){
document.getElementById("pingouin").src='C:\Users\name\Desktop\images1/pingouin_rouge_grand.png';
}
<body>
<img src='C:\Users\name\Desktop\images1/pingouin_grand.png' id="pingouin">
<img src='C:\Users\name\Desktop\images1/pingouin_rouge_grand.png' id="pingouin_rouge">
<button onclick="changerPingouin();">
Changer de Pingouin
</button>
The first image shows and I have other functions that work with it. However when I click the button, it doesn't display the other image. For this reason I haven't started the part where another click of the button changes the image back to the first one "pingouin_grand".Thanks.
Error:
/C:/UsersnameDesktopimages1/pingouin_rouge_grand.png:1 GET file:///C:/UsersnameDesktopimages1/pingouin_rouge_grand.png net::ERR_FILE_NOT_FOUND Image (async) changerPingouin # Module_8PLs.html:21 onclick # Module_8PLs.html:89
From the error, the file is not found because the path read is C:/UsersnameDesktopimages1/pingouin_rouge_grand.png. There are no backslash separating the directories.
The backslash needs to be escaped. In JavaScript, the backslash is used to escape special characters, such as newlines (\n). If you want to use a literal backslash, a double backslash has to be used. Try changing the image source to 'C:\\Users\\name\\Desktop\\images1\\pingouin_rouge_grand.png'. Do the same to the first image.
Related
I'd like to replace Emojis on my website with custom images. That itself would not be a problem in PHP:
$string = "This is a laughing emoji 😂";
echo str_replace($string, "😂", ":'D"); //or replace with an image
However, how do I manage that if someone copies the text, they will be able to copy the text with the emoji and not the replaced image? Like keeping the char 😂 😂 but only changing the outcome so they will look the same for every user. Is that even possible at all?
One way to do this would be to replace the emoji with an <img> image tag, but set the alt attribute of the image to the original emoji. Then, if the result is copied somewhere that only accepts text, the alt text will be used.
"Run" this snippet to see an example:
Hello <img alt="😀" src="data:image/png;base64,R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMlWLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7"> world!
<br/>
<textarea cols="25" rows="3">Paste here</textarea>
The emoji between the two words will look like a Gmail emoji, until you copy the entire line of text somewhere.
Of course, you can use a normal URL instead of a data: URL.
No, each system has its own sets of fonts ( including emojis ) which is why they appear different on android vs iOS. The only way you would be able to add something would be outside of the system typeface, i.e. icon sets. You could either include images or links to images.
<img src="imageLocation" alt="altTextorImage">
Is it possible, probably using javascript, to jump to a particular sentence (string) via a link on a website?
Like an anchor, only without the anchor in HTML.
This is an example from the search results, searchstring was "content directory":
Result: planets/ on line 20: <br>
If you create a folder within the content directory (e.g. <code class="hljs lua">content/<span class="hljs-built_in">sub</span></code>) and...
After the link has been opened, the browser should jump to this line (The line number is of course only the one from the searched text file.) and like to color the search string.
I found some usefull script: http://www.seabreezecomputers.com/tips/find6.htm
It offers a On-Side-Search-Button
I've been trying to do something simple, i think, let me explain:
I have an BPMS software where a send an e-mail at the end of the process, this e-mail is an HTML page that i created, inside the HTML page we have some identifying codes that get a field value from an previously form, some strings. The problem is, when i transfer that value to the HTML page, obviously the "Enter" key doesn't work like the "br" tag, so i made a simple javascript to replace the "enter" for the "br". It worked, but when i send the e-mail my ID is changed and they put an "x_" prefix, so there goes my question.
Can i stop it or there is some other way to do it?
The code is below:
<p id="informacoes">
TEST
TEST
</p>
<script>
var strMessege = document.getElementById('informacoes');
strMessege.innerHTML = strMessege.innerHTML.replace(/(?:\r\n|\r|\n)/g, '<br />');
</script>
It seems like your end goal here is to retain original line breaks present in the source code. I think your best bet would be to address this using CSS.
Take a look at the CSS property white-space, MDN: white-space property
By default, CSS collapses white space (e.g. multiple non-breaking ("regular") spaces, tabs, and newlines) into, effectively, a single regular space. In your example, the line breaks that you see in the source code are being collapsed and so they will not be rendered by the browser or email client.
Try using CSS to set a different white-space property, like
#informacoes {
white-space: pre-line;
/* depending on your use case,
a different value might work better */
}
Property values other than white-space: normal (which is the default) will change whether and how white space, including new lines, are collapsed when rendering from the source code to the screen.
I have used below syntzx to replace single quote with double single quote issue
str.replace(/'/g,"''");
but it's replace everytime when it load page. like
I have text
" Test's and test's page and test's event"
then first time ,it will be
" Test''s and test''s page and test''s event"
then again
" Test'''s and test'''s page and test'''s event"
then next loading
" Test''''s and test''''s page and test''''s event"
can you please help to get just single to double single quote only?
If it's safe to assume that there won't be three or more quotes in a row, try this:
str.replace(/'+/g,"''")
If the assumption is not safe, and you just want to replace "a quote by itself" with two quotes, leaving multi-quotes alone, try this:
str.replace(/''?('*)/g,"''$1");
That being said, you might want to look into why it's replacing more than once in the first place ;)
Firstly I'm new to the community as an user, and I want to say it is a great one.
My question is that I want to get an URL from an <a href="" element, using <alt="new"> or the name of an image used in that <td> part from a webpage that changes daily and doesn't belong to me.
So far I've coded something to download the page with wget to a text file, then searched for the image or alt variable. Even if it brought me the part that the searched items existed, it doesn't include the <a href part I needed that's located just before the image.
edit: i managed to get the line below, i just need to get the url inside with batch, or redirect to it with javascript, but since title and url changes, it was challenging. Any help ?
<td width="150" align="left" valign="top"><b><u>"SOMETEXT"</u></b>
Using your provided code:
set "x=<td width="150" align="left" valign="top"><b><u>"SOMETEXT"</u></b>"
set "x=%x:<=%" & :: Remove Redirection Character
set "x=%x:>=%" & :: Remove Redirection Character
set x=%x:*href=% & :: Remove everything up till href=
set x=%x:~2% & :: Trim ="
set x=%x:"='% & :: Replace Double Quotes with Single Quotes
set "x=%x:' =" & rem % & :: Remove everything after URL
echo %x%
Notice the double quotes, they are essential for removing the html tag deliminators < and >, because those are redirection characters, which will cause errors unless surounded by double quotes.
You can copy and paste the above code directly into the command prompt to test it.
If I understand you corectly you want do get from HTML file link contained in <a href="" ?
first solution that comes to my mind is to download entire HTML and use python and BeautifulSoup library to parse this file and get all 'hrefs'. Is that what you mean?