Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

This answerThis answer provides the jQuery and normal JS methods, but this is shortest without using the DOM:

unescape(escape("It's > 20% less complicated this way.")) 

Escaped string: It%27s%20%3E%2020%25%20less%20complicated%20this%20way.

If the escaped spaces bother you, try:

unescape(escape("It's > 20% less complicated this way.").replace(/%20/g, " ")) 

Escaped string: It%27s %3E 20%25 less complicated this way.

Unfortunately, the escape() function was deprecated in JavaScript version 1.5. encodeURI() or encodeURIComponent() are alternatives, but they ignore ', so the last line of code would turn into this:

decodeURI(encodeURI("It's > 20% less complicated this way.").replace(/%20/g, " ").replace("'", '%27')) 

All major browsers still support the short code, and given the number of old websites, i doubt that will change soon.

This answer provides the jQuery and normal JS methods, but this is shortest without using the DOM:

unescape(escape("It's > 20% less complicated this way.")) 

Escaped string: It%27s%20%3E%2020%25%20less%20complicated%20this%20way.

If the escaped spaces bother you, try:

unescape(escape("It's > 20% less complicated this way.").replace(/%20/g, " ")) 

Escaped string: It%27s %3E 20%25 less complicated this way.

Unfortunately, the escape() function was deprecated in JavaScript version 1.5. encodeURI() or encodeURIComponent() are alternatives, but they ignore ', so the last line of code would turn into this:

decodeURI(encodeURI("It's > 20% less complicated this way.").replace(/%20/g, " ").replace("'", '%27')) 

All major browsers still support the short code, and given the number of old websites, i doubt that will change soon.

This answer provides the jQuery and normal JS methods, but this is shortest without using the DOM:

unescape(escape("It's > 20% less complicated this way.")) 

Escaped string: It%27s%20%3E%2020%25%20less%20complicated%20this%20way.

If the escaped spaces bother you, try:

unescape(escape("It's > 20% less complicated this way.").replace(/%20/g, " ")) 

Escaped string: It%27s %3E 20%25 less complicated this way.

Unfortunately, the escape() function was deprecated in JavaScript version 1.5. encodeURI() or encodeURIComponent() are alternatives, but they ignore ', so the last line of code would turn into this:

decodeURI(encodeURI("It's > 20% less complicated this way.").replace(/%20/g, " ").replace("'", '%27')) 

All major browsers still support the short code, and given the number of old websites, i doubt that will change soon.

added current official version to compare with current unofficial version
Source Link
Cees Timmerman
  • 20.3k
  • 11
  • 99
  • 138

This answer provides the jQuery and normal JS methods, but this is shortest without using the DOM:

unescape(escape("It's > 20% less complicated this way.")) 

Escaped string: "It%27s%20%3E%2020%25%20less%20complicated%20this%20way."It%27s%20%3E%2020%25%20less%20complicated%20this%20way.

If the escaped spaces bother you, try:

unescape(escape("It's > 20% less complicated this way.").replace(/%20/g, " ")) 

Escaped string: "It%27s %3E 20%25 less complicated this way."It%27s %3E 20%25 less complicated this way.

Note: This is only for easy embedding and doesn't break embedded HTML and scriptsUnfortunately, for whichthe this answer providesescape() function was deprecated in JavaScript version 1.5. encodeURI() or encodeURIComponent() are alternatives, but they ignore ', so the jQuerylast line of code would turn into this:

decodeURI(encodeURI("It's > 20% less complicated this way.").replace(/%20/g, " ").replace("'", '%27')) 

All major browsers still support the short code, and normal JS methodsgiven the number of old websites, i doubt that will change soon.

unescape(escape("It's > 20% less complicated this way.")) 

Escaped string: "It%27s%20%3E%2020%25%20less%20complicated%20this%20way."

If the escaped spaces bother you, try:

unescape(escape("It's > 20% less complicated this way.").replace(/%20/g, " ")) 

Escaped string: "It%27s %3E 20%25 less complicated this way."

Note: This is only for easy embedding and doesn't break embedded HTML and scripts, for which this answer provides the jQuery and normal JS methods.

This answer provides the jQuery and normal JS methods, but this is shortest without using the DOM:

unescape(escape("It's > 20% less complicated this way.")) 

Escaped string: It%27s%20%3E%2020%25%20less%20complicated%20this%20way.

If the escaped spaces bother you, try:

unescape(escape("It's > 20% less complicated this way.").replace(/%20/g, " ")) 

Escaped string: It%27s %3E 20%25 less complicated this way.

Unfortunately, the escape() function was deprecated in JavaScript version 1.5. encodeURI() or encodeURIComponent() are alternatives, but they ignore ', so the last line of code would turn into this:

decodeURI(encodeURI("It's > 20% less complicated this way.").replace(/%20/g, " ").replace("'", '%27')) 

All major browsers still support the short code, and given the number of old websites, i doubt that will change soon.

added note
Source Link
Cees Timmerman
  • 20.3k
  • 11
  • 99
  • 138
unescape(escape("It's > 20% less complicated this way.")) 

Escaped string: "It%27s%20%3E%2020%25%20less%20complicated%20this%20way."

If the escaped spaces bother you, try:

unescape(escape("It's > 20% less complicated this way.").replace(/%20/g, " ")) 

Escaped string: "It%27s %3E 20%25 less complicated this way."

Note: This is only for easy embedding and doesn't break embedded HTML and scripts, for which this answer provides the jQuery and normal JS methods.

unescape(escape("It's > 20% less complicated this way.")) 

Escaped string: "It%27s%20%3E%2020%25%20less%20complicated%20this%20way."

If the escaped spaces bother you, try:

unescape(escape("It's > 20% less complicated this way.").replace(/%20/g, " ")) 

Escaped string: "It%27s %3E 20%25 less complicated this way."

unescape(escape("It's > 20% less complicated this way.")) 

Escaped string: "It%27s%20%3E%2020%25%20less%20complicated%20this%20way."

If the escaped spaces bother you, try:

unescape(escape("It's > 20% less complicated this way.").replace(/%20/g, " ")) 

Escaped string: "It%27s %3E 20%25 less complicated this way."

Note: This is only for easy embedding and doesn't break embedded HTML and scripts, for which this answer provides the jQuery and normal JS methods.

typo
Source Link
Cees Timmerman
  • 20.3k
  • 11
  • 99
  • 138
Loading
Source Link
Cees Timmerman
  • 20.3k
  • 11
  • 99
  • 138
Loading