File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ < html >
2+ < body >
3+ You sent our website the following info:
4+
5+ </ body >
6+ < script >
7+ // 1. Get the URL fragment (hash)
8+ const fragment = window . location . hash ;
9+
10+ // 2. Check if a fragment exists
11+ if ( fragment ) {
12+ const base64EncodedString = fragment . substring ( 1 ) ;
13+
14+ try {
15+ // 3. Base64 decode the string using atob()
16+ const decodedString = atob ( base64EncodedString ) ;
17+
18+ // 4. Create a new element to append the content (e.g., a div or p tag)
19+ const newElement = document . createElement ( 'div' ) ;
20+ newElement . textContent = decodedString ;
21+ newElement . style . padding = '20px' ;
22+ newElement . style . border = '1px solid black' ;
23+
24+ // 5. Append the new element to the document body
25+ document . body . appendChild ( newElement ) ;
26+
27+ console . log ( "Decoded and appended:" , decodedString ) ;
28+
29+ } catch ( error ) {
30+ // Handle cases where the string might not be valid Base64
31+ console . error ( "Failed to decode Base64 string:" , error ) ;
32+ }
33+ } else {
34+ console . log ( "No URL fragment found." ) ;
35+ }
36+ </ script >
37+ </ html >
You can’t perform that action at this time.
0 commit comments