0

I am applying a javascript, but it fires the error:

**missing ; before statement**

String str = document.location.href;
alert(str);
str.replace( "/blogs/-/blogs", "blogs" );

Your any suggestions are appreciated.

2
  • 2
    this is javascript.everything is var. Commented Mar 8, 2013 at 7:08
  • 1
    don't confuse Javascript with Java :) Commented Mar 8, 2013 at 7:09

1 Answer 1

7

Change

String str = document.location.href;

to

var str = document.location.href;

You don't declare variables with a type in JavaScript but with the var keyword.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.