Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
document.write('<button style="width:100;height:20" onClick="window.location='/scripts/broker.exe?\"_program=websas.COMPLAINTS_input6.sas"\&_debug=0&CCNUM=C0000582 '">Upload Image</button> ')



<pre>I try to executed on console developer tool


What I have tried:

when I opened developer tool in google chrome and put
Copy Code
<pre>document.write('<button style="width:100;height:20" onClick="window.location='/scripts/broker.exe?_program=websas.COMPLAINTS_input6.sas&_debug=0&CCNUM=C0000582 '">Upload Image</button> ')


control on console then I got error -

Uncaught SyntaxError: Invalid left-hand side in assignment

I tried to fix issues but unable to fixed this issues please help me

Thanks
Posted
Updated 13-Jul-22 3:38am
Comments
CHill60 13-Jul-22 8:46am    
Please edit your question and use the proper pre-tags and remove the rogue items such as "Copy Code" - it is impossible to tell what you actually put into the tool
Member 12183079 13-Jul-22 9:52am    

<button style="width:100;height:20" onClick="window.location='"'"'/scripts/broker.exe?_program=websas.COMPLAINTS_input6.sas&_debug=0&CCNUM='CCNUM"'"'">Upload Image</button> ';
0x01AA 13-Jul-22 8:49am    
Try escaping the single quotes document.write('<button style="width:100;height:20" onClick="window.location=\'/scripts/broker.exe?_program=websas.COMPLAINTS_input6.sas&_debug=0&CCNUM=C0000582 \'">Upload Image</button> ')
Member 12183079 13-Jul-22 9:53am    

<button style="width:100;height:20" onClick="window.location='"'"'/scripts/broker.exe?_program=websas.COMPLAINTS_input6.sas&_debug=0&CCNUM='CCNUM"'"'">Upload Image</button> ';
0x01AA 13-Jul-22 10:08am    
Don't do it like this, it's not readable. Do it like I show in the comment, simply escape the two single quotes for location parameter in the string with backslash, e.g.: "\' any text\'"

1 solution

You need to escape the single quotes in your output string.

Example:
document.write('There\'s an escaped single quote in that text');


More info about js strings and escaping you find here: How to Escape Quotes in a String using JavaScript | bobbyhadz[^]

[Edit]
Final example with text in the question (tested and it works):
document.write('<button style="width:100;height:20" onClick="window.location=\'/scripts/broker.exe?_program=websas.COMPLAINTS_input6.sas&_debug=0&CCNUM=C0000582\'">Upload Image</button> ')

There are two single quotes which you need to escape:
\'/scripts/broker.exe?_program=websas.COMPLAINTS_input6.sas&_debug=0&CCNUM=C0000582\'
 
Share this answer
 
v3
Comments
Member 12183079 13-Jul-22 9:49am    
Could you please write code-

<button style="width:100;height:20" onClick="window.location='"'"'/scripts/broker.exe?_program=websas.COMPLAINTS_input6.sas&_debug=0&CCNUM='CCNUM"'"'">Upload Image</button> ';
0x01AA 13-Jul-22 10:03am    
See my updated answer.
If that is fixed, I assume you will have then the next problem, that a browser does block this because of security ;)
Member 12183079 13-Jul-22 10:14am    
not working

please check in this code-

<button style="width:100;height:20" onClick="window.location='"'"'/scripts/broker.exe?_program=websas.COMPLAINTS_input6.sas&_debug=0&CCNUM='CCNUM"'"'">Upload Image</button> '; 
0x01AA 13-Jul-22 10:20am    
What means 'not working'?
Still the same error message "Uncaught SyntaxError: Invalid left-hand side in assignment"?
With what you surround the whole string? I hope with single quotes...

Just recognized while writing.... now you miss a double quote... please concentrate more ;)

<button style="width:100;height:20" onClick="window.location=\'/scripts/broker.exe?_program=websas.COMPLAINTS_input6.sas&_debug=0&CCNUM=C0000582\'">Upload Image</button>
0x01AA 13-Jul-22 10:22am    
Ooooh sh*t, looks like CP does reformat then and when and replaces escaped quotes....?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900