Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Javascript, Search replace

Featured Replies

Help. My javascript knowlegde is still limited. Here is my script.

 

<script language='javascript'>

var mydiv = document.getElementById("id");
mydiv.innerHTML = mydiv.innerHTML.replace("/abe/", "Hello World!");

</script>

 

 

<div id="mydiv">
<p>
Bogen, som handler om etik, blev skrevet i <b>år abe 45</b> f.kr. men var meget populær i renæssancen.
</p>
</div>

 

What i am trying to do, is to define som innerHTML, "abe", and replace it with "Hello World!". But it does not work. Help?

 

/jimmy <_<

  • Author

Nevermind,

 

i found a way..... sharing:

 

	var innerhtmllol = document.getElementById('mydiv').innerHTML;
var innerhtmlreplace = "<img src=\"http://www.w3schools.com/images/w3default80.jpg\" width=\"20px\" height=\"20px\">"
innerhtmllol = innerhtmllol.replace(/ \:\) /g, innerhtmlreplace);
document.getElementById('mydiv').innerHTML = innerhtmllol;

var innerhtmllol = document.getElementById('mydiv').innerHTML;
var innerhtmlreplace = "<img src=\"http://www.killersites.com/mvnforum/mvnforum/getavatar?memberid=1908\" width=\"20px\" height=\"20px\">"
innerhtmllol = innerhtmllol.replace(/ \;\) /g, innerhtmlreplace);
document.getElementById('mydiv').innerHTML = innerhtmllol;

it could be because your REGEX was wrong.

 

you were using:

"/abe/"

 

whereas you may find success with just:

/abe/

(no quotes)

  • 5 weeks later...

php, I tried that and it didnt work either?? I no he already got it but im just wondering why it didnt work the first way??

php, I tried that and it didnt work either?? I no he already got it but im just wondering why it didnt work the first way??

 

Due to what Penguin said. His regex was wrong.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.