Let's say my site is www.domain.com and I want to add a link to it that goes to www.domain123.com. When a person clicks the link and gets to www.domain123.com, I want all links on THAT site to be disabled, and I want the only way for the person to get out of www.domain123.com is by click Back (<----) to my site. How can I do this? Its creating a dead end on www.domain123.com, but I dont have access to www.domain123.com's files because its not mine.

Dani AI

Generated

Short answer: you cannot reliably disable links on a site you do not control. Browsers and modern web security are built so one origin cannot inject behavior into another; that is the technical reason why the tricks discussed in the thread won't work consistently today. As and noted, any solution that tries to “take control” of a visitor’s view is fragile and hostile to users.

Two practical, lawful alternatives that achieve a similar outcome:

  • Serve a read‑only preview (server side) — capture the external page as an image or static snapshot with a headless browser and show that to visitors. It gives a “dead end” preview without trying to modify the remote site; provide a clear “Open original site” link if the user wants the live page. Puppeteer is a common tool for snapshots:
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://www.domain123.com', { waitUntil: 'networkidle2' });
  await page.screenshot({ path: 'preview.png', fullPage: true });
  await browser.close();
})();
  • If interactive behavior is required, implement a reverse‑proxy on your server that fetches and rewrites the external HTML so links point back through your proxy. This is technically possible but complex: you must rewrite URLs, handle relative paths, rewrite JS/XHR endpoints, manage cookies/sessions, and cope with HTTPS and modern defenses. It also raises copyright and Terms‑of‑Service issues.

Important notes and references:

  • Same‑origin policy prevents cross‑origin scripting; that is why you cannot reliably alter another domain’s page (see MDN on same‑origin policy)
  • Many sites use frame/embedding protections such as X-Frame-Options or CSP frame‑ancestors; those will block naive framing (see MDN on X-Frame-Options and frame‑ancestors)

Do not trap users. A transparent interstitial or an explicit preview with a clear “Leave/Return” control is far better UX and avoids legal/ethical problems. If the external site’s behavior is critical to your workflow, request permission or a formal integration.

Recommended Answers

All 3 Replies

I want to take control of my visitors' computers.

Write a Web browser that supports this somehow, and then ask your users to download this Web browser, and see if they like it.

Well, there might be a way to do that... but it's not something I'd ever do, so I haven't investigated it. I strongly discourage you from doing this, for several reasons. Perhaps the most important, it would violate user expectations. A user expects to be able to click hyperlinks. Finding themselves suddenly unable to do so, they'd most likely close the browser, rather than clicking "back". Also, it is probably unethical, though I'm willing to give you the benefit of a doubt and assume you have a perfectly honest and valid reason for wishing to do this.

That said, look into "screen-scraping". You could get the content of the target site, and output it into a new window, with your own code to attached (such as a CSS style that set all anchor tags to "display: none"). You'll need server-side code for that.

I'm pretty sure that JavaScript won't work, because browsers won't "trust" or allow a script to run across domains.

You could put their site in an iframe and then position something transparent above the iframe. (And then your visitors wonder why they can't scroll.) Then you could expect a C&D in the mail.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.