Coding Global Background
Coding Global
\n```\n\nHowever, if `document.write` is used after the page has finished loading, it will overwrite the entire content of the page, which is usually not desired. Make sure that any manipulation of the page's content is done responsibly, considering the above","dateModified":"2024-01-20T18:43:20.121Z"},{"@type":"Comment","author":{"@type":"Person","name":"Deleted User","url":"https://discord.com/users/456226577798135808","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"datePublished":"2024-01-20T18:43:20.041Z","text":"points about redirection and page unloading.","dateModified":"2024-01-20T18:43:22.471Z"},{"@type":"Comment","author":{"@type":"Person","name":"Deleted User","url":"https://discord.com/users/456226577798135808","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"datePublished":"2024-01-20T18:44:16.338Z","text":"**<@1162847350956511233> exoticcitron's Question:**\n\n`cant i get another html code to show from another file adter a page has been redirected to a subdomain such as example.com/dfhiusaIUH , then it shows another code when it reaches there`\n\nNo, once you've redirected to another page (e.g., `example.com/dfhiusaIUH`), the code from the original page will not continue to run. The new page loaded at the redirected URL will have to have its own HTML, JavaScript, or other resources that dictate what is displayed to the user and any dynamic behavior on that page.\n\nIf you want to show something specific after the redirect—a particular HTML code snippet or run some JavaScript—you'll need to include that HTML or JavaScript in the page hosted at the new URL (`example.com/dfhiusaIUH`). \n\nHere's what you need to do:\n\n1. Include the HTML or JavaScript you want to execute in the page at the redirect URL.\n2. Set up the actual redirection in your original page:\n\n```html\n\n\n```\n\n3. In the HTML file located at `example.com/dfhiusaIUH`, include the code you want to execute when the page is loaded:\n\n```html\n\n\n\n\n\n
Some HTML to show on the new page.
\n\n\n\n\n\n```\n\nWhen users are redirected to `example.com/dfhiusaIUH`, the code within that page will run automatically. Remember that communication between the two pages is limited once redirection happens because they are separate documents running in separate contexts. If you need to pass data between them, you must use URL parameters, cookies, or local storage depending on your requirements.","dateModified":"2024-01-20T18:45:17.826Z"},{"@type":"Comment","author":{"@type":"Person","name":"Deleted User","url":"https://discord.com/users/456226577798135808","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"datePublished":"2024-01-20T18:46:25.927Z","text":"**<@1162847350956511233> exoticcitron's Question:**\n\n`this is my code: Random Redirect

If you are not redirected, click here.

- now how do i implement this some html code in the randomLmao() function so it displays another website page code after the user has been redirected`\n\nTo achieve what you're describing (displaying specific content after the user is redirected to a new random URL), you will need to have control over the server-side code or the HTML content at those random URLs you're generating.\n\nLet's break down the necessary steps you'd need to follow:\n\n1. Set up your server to handle the random paths and serve the same HTML or execute the same server-side code for each random path.\n2. When a random URL is hit, the server-side","dateModified":"2024-01-20T18:46:42.795Z"},{"@type":"Comment","author":{"@type":"Person","name":"Deleted User","url":"https://discord.com/users/456226577798135808","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"datePublished":"2024-01-20T18:46:43.031Z","text":"logic would display the \"some html code obfuscated\" or whatever you intend to present to the user.\n\nFor the first part, it looks like your JavaScript already generates a random path and redirects the user to it. Here's a simplified version of the redirect part:\n\n```html\n\n\n\n \n Random Redirect\n \n\n\n

If you are not redirected, click here.

\n\n\n```\n\nFor the second part, here's what you need to do, but this would depend on the backend technology you're using. Let's assume you're using Node.js with Express:\n\n```javascript\nconst express = require('express');\nconst app = express();\nconst port = 3000;\n\napp.get('/promotion-:randomPath', (req, res) => {\n // Now instead of serving a dynamic page, you serve a specific HTML file or content.\n res.sendFile('/path/to/your/specific.html');\n // Or if you want to serve HTML content:\n // res.send('Your HTML content goes here');\n});\n\napp.listen(port, () => {\n console.log(`Server running at http://localhost:${port}`);\n});\n```\n\nIn `specific.html`, or in the HTML you send directly, you would include the","dateModified":"2024-01-20T18:47:46.875Z"},{"@type":"Comment","author":{"@type":"Person","name":"Deleted User","url":"https://discord.com/users/456226577798135808","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"datePublished":"2024-01-20T18:47:47.083Z","text":"content you want to display to the user after the redirect:\n\n```html\n\n\n\n \n

This is the content a user sees after they've been redirected to a promotion page.

\n \n \n\n\n```\n\nReplace `/path/to/your/specific.html` with the actual file path to your HTML file.\n\n**Important**: Keep in mind that you should not use `document.write` after the document has finished loading, as it will overwrite the entire document, which is probably not what you want here. Instead, use proper DOM manipulation methods to update the page content.\n\nBy following these steps, users will be redirected to random URLs (such as `/promotion-ABCD1234`), and each of these paths will serve the content or execute the function you defined in your server-side logic.","dateModified":"2024-01-20T18:48:19.248Z"},{"@type":"Comment","author":{"@type":"Person","name":"Deleted User","url":"https://discord.com/users/456226577798135808","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"datePublished":"2024-01-20T18:48:54.213Z","text":"**<@1162847350956511233> exoticcitron's Question:**\n\n`but im using html/js/css only, would that node.js work in that?`\n\nIf you only have HTML, JavaScript, and CSS (without a server-side component like Node.js), you'll be limited because you won't be able to dynamically handle requests for those random URLs; a typical HTML/JS/CSS-only website requires that the files exist at the server statically.\n\nWhat you can do with just HTML, JS, and CSS is set up your \"randomLmao()\" function to display dynamic content on the page before redirecting. However, once you use `window.location.href` to redirect, you cede control to the new URL's content.\n\nIf you want all the random URLs to show the same content, then you could create one HTML file with the desired content and simply redirect to that static URL, ignoring the random string in this scenario.\n\nHere's an example of how you might do this:\n\n```javascript\n\n```\n\nThen, in the body section:\n\n```html\n\n

Your dynamic content will display here, then you'll be redirected.

\n\n```\n\nWhat this does is b","dateModified":"2024-01-20T18:49:57.238Z"},{"@type":"Comment","author":{"@type":"Person","name":"Deleted User","url":"https://discord.com/users/456226577798135808","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"datePublished":"2024-01-20T18:49:57.549Z","text":"riefly show content created by `randomLmao()` before redirecting to 'staticPage.html'. You need to have a file named 'staticPage.html' at your webserver with the content you want to show after redirecting.\n\nTo truly handle dynamic paths like '/promotion-ABCD1234', you would need a web server capable of URL rewriting or similar server-side functionality, which is not possible with pure client-side HTML/JS/CSS.","dateModified":"2024-01-20T18:50:10.384Z"},{"@type":"Comment","author":{"@type":"Person","name":"Deleted User","url":"https://discord.com/users/456226577798135808","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"datePublished":"2024-01-21T10:27:09.338Z","text":"Hello, do you still need help?"}]}

redirect works but code after doesnt

Archiviert 2 years ago
10 Nachrichten
0 Mitglieder
Erstellt 2 years ago
Aktualisiert 2 years ago
In Discord öffnen
E
Exo
heya, so i was learning how to redirect code and i've been trying to randomise redirects.

essentially, i expected the code to run the redirect and it has, it redirected to the page, but then it will run some code however resulting in an error sych has "it cant find the file, or run the code after it", i assume its because i'm using document.write after the redirect? please help

below is my code:
https://pastebin.com/8yA91AAs

it doesnt run the code after redirecting it, but the redirect works

Antworten (10)