+ 1

my problem in running javascript !

hello everyone i want when i click on ok. my code call ExitMassage function ,so i see goodbay massage but i cann't see this result. <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body onload="exit()"> </body> <script> function exit() { var x = confirm("do you want exit?"); if (x == true) { ExitMassage('alireza', 'Babaei') function ExitMassage(FirstName, lastName) { document.write = (' Good bay ' + FirstName + lastName); } } else document.URL = '#'; } </script> </html>

5th Dec 2018, 12:43 PM
Alireza Babaei
Alireza Babaei - avatar
3 odpowiedzi
+ 4
You don't correctly use document.write... it's a function, not a property, so in your code you assign it a value (with the equal sign), instead of calling it ^^ Correct code should be: document.write(' Good bay ' + FirstName + lastName);
5th Dec 2018, 1:41 PM
visph
visph - avatar
+ 1
What is the expected result of this code when the confirm() is false?
5th Dec 2018, 1:37 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 1
when confirm is false i dont see any change ,and i stay in my own first page that i am.
5th Dec 2018, 1:40 PM
Alireza Babaei
Alireza Babaei - avatar