我正在创建一个有免费编辑的网站。网站是http://pozzistore.com。编辑器,因为我使用的是免费版本,允许我只有5页,但我需要更多。
如果你访问我的网站,在主页上你会看到不同的按钮将你带到不同的页面,这就是我的问题:没有使用4种不同的页面,而是有一种方法可以使用JavaScript来检查按下哪个按钮,打开一个新页面并显示特定的内容?
我的意思是,这是我网站上的两个不同的页面:
http://pozzistore.com/P1.html
http://pozzistore.com/P2.html
要访问此页面,必须单击两个不同的按钮。我希望JavaScript检查按下的按钮并打开一个新页面,例如,如果我按下新页面上的第一个按钮,它将显示http://pozzistore.com/P1.html,如果我按下同一页上的第二个按钮,则显示http://pozzistore.com/P2.html。
我不能使用PHP,因为我使用GitHub托管网站,所以我没有Apache。
发布于 2022-04-24 08:46:33
您可以使用open()方法。
<button onclick="openTab('myurl.com/path/to/the/first/page')">First page</button>
<button onclick="openTab('myurl.com/path/to/the/second/page')">Second page</button>
<button onclick="openTab('myurl.com/path/to/the/third/page')">Third page</button>
...let tab=open();//that code open a new empty page at the begining, returns a `window` object (so you can use tab.alert(), tab.consloe.log() etc.)
function openTab(url) {
 tab.location.href=url; //use the window.location object
  }https://stackoverflow.com/questions/71986667
复制相似问题