+ 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.

5th Dec 2019, 5:04 AM
swali1
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>
5th Dec 2019, 6:22 AM
Ipang
+ 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 ..👍👍👍
5th Dec 2019, 6:48 AM
swali1
+ 1
You're very welcome buddy ✌
5th Dec 2019, 6:51 AM
Ipang