Javascript Shopify公共应用程序安装按钮重定向古怪
这是一个奇怪的现象,发生在商店的管理员用户点击安装按钮之后 用户单击“获取”按钮,系统运行正常。用户看到的下一个页面是“安装”按钮页面 当用户单击install(安装)时,会向我的服务器回拨一个电话,我会发出请求并返回适用的令牌 然后访问我的服务器,我提供一个页面,该页面在浏览器的完整窗口中呈现。我希望它位于Javascript Shopify公共应用程序安装按钮重定向古怪,javascript,pug,shopify,Javascript,Pug,Shopify,这是一个奇怪的现象,发生在商店的管理员用户点击安装按钮之后 用户单击“获取”按钮,系统运行正常。用户看到的下一个页面是“安装”按钮页面 当用户单击install(安装)时,会向我的服务器回拨一个电话,我会发出请求并返回适用的令牌 然后访问我的服务器,我提供一个页面,该页面在浏览器的完整窗口中呈现。我希望它位于商店的/admin/apps/\u myapp\u页面的iFrame中 如果我关闭页面。然后导航到商店的/admin/apps/\u myapp\u页面I host现在在iFrame中按照您
商店的/admin/apps/\u myapp\u
页面的iFrame中
如果我关闭页面。然后导航到商店的/admin/apps/\u myapp\u
页面I host现在在iFrame中按照您的预期正确呈现
和提示/想法。单击“安装”按钮时发生了什么或没有发生什么
但这是我发送给“安装”解决方案的页面。我相信我有正确的设置。但也许你会看到一些我没有看到的东西。这是翡翠色/帕格色的
extends layout
block content
script(src="/jquery/dist/jquery.js")
script.
function doThePost() {
alert('hello world');
}
h1= title
p Welcome to #{title}
p
p
p
input(type="text", id="shopUrl", name="shopUrl", value="#{shopUrl}", hidden="hidden")
input(type="text", id="shop", name="shop", value="#{shop}", hidden="hidden")
p
button(onclick='doThePost()') v1Demo
p
p end
script(type="text/javascript").
var shpUrl = $('#shopUrl').val();
var shp = $('#shop').val();
// If the current window is the 'parent', change the URL by setting location.href
if (window.top == window.self) {
window.top.location.href = 'https://' + shpUrl + '/admin/oauth?shop=' + shp;
// If the current window is the 'child', change the parent's URL with postMessage
} else {
message = JSON.stringify({
message: "Shopify.API.remoteRedirect"
, data: { location: window.location.origin + '/admin/oauth?shop=' + shp }
});
window.parent.postMessage(message, 'https://' + shpUrl);
}