+ 1
How can a page be forced to load another page in JavaScript?
My code : <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <script language="JavaScript" type="text/javascript" > <location.href="https://www.sololearn.com/.html";></script> </body> </html> error message: JavaScript Console Uncaught SyntaxError: Unexpected token '<' Line: 3 Please rectify my mistake and explain how to force load a page in JavaScript.
3 Antworten
+ 2
Because you have a '<' before the redirect instruction, and a '>' after. Remove those and try again.
<script language="JavaScript" type="text/javascript">
location.href="https://www.sololearn.com/.html";
</script>
+ 1
Thanks @Ipang
this is the code that worked
<script language="JavaScript" type="text/javascript">
location.href="https://www.sololearn.com";
</script>
I had to remove /.html also it loaded the page in the output
full code:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
location.href="https://www.sololearn.com";
</script>
</body>
</html>
Thanks again ..👍👍👍
+ 1
You're very welcome buddy ✌