How to redirect a page amp?
up vote
-1
down vote
favorite
I need to adapt the following javascript code to an amp page.
<select id="url">
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>
<input type="button" value='ir' onclick='ir()'>
<script>
function ir(){
var url=document.getElementById("url").value;
location.href=url;
}
</script>
It's possible?
In the documentation I did not find the answer.
amp-html
add a comment |
up vote
-1
down vote
favorite
I need to adapt the following javascript code to an amp page.
<select id="url">
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>
<input type="button" value='ir' onclick='ir()'>
<script>
function ir(){
var url=document.getElementById("url").value;
location.href=url;
}
</script>
It's possible?
In the documentation I did not find the answer.
amp-html
Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
– Jonathan Lam
Apr 25 at 16:36
please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
– Mozahler
Apr 25 at 17:16
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I need to adapt the following javascript code to an amp page.
<select id="url">
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>
<input type="button" value='ir' onclick='ir()'>
<script>
function ir(){
var url=document.getElementById("url").value;
location.href=url;
}
</script>
It's possible?
In the documentation I did not find the answer.
amp-html
I need to adapt the following javascript code to an amp page.
<select id="url">
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>
<input type="button" value='ir' onclick='ir()'>
<script>
function ir(){
var url=document.getElementById("url").value;
location.href=url;
}
</script>
It's possible?
In the documentation I did not find the answer.
amp-html
amp-html
edited Nov 9 at 11:23
Bachcha Singh
2,16721025
2,16721025
asked Apr 25 at 16:33
python
61
61
Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
– Jonathan Lam
Apr 25 at 16:36
please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
– Mozahler
Apr 25 at 17:16
add a comment |
Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
– Jonathan Lam
Apr 25 at 16:36
please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
– Mozahler
Apr 25 at 17:16
Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
– Jonathan Lam
Apr 25 at 16:36
Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
– Jonathan Lam
Apr 25 at 16:36
please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
– Mozahler
Apr 25 at 17:16
please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
– Mozahler
Apr 25 at 17:16
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
You are using button and onclick function, in place of this in AMP you can use anchor tag <a href="Value">Value</a>
and change the url using `amp-bind'
You can use amp-bind
to achieve your goal
Here is working URL
add JS in header
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
Add code in body
<div class="wrapper">
<select on="change:AMP.setState({ url: event.value })">
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>
<a [href]="url" href="home">ir</a>
</div>
Updated - if some one want to redirect on option change than use navigateTo
action
Example :
<select on="change:AMP.navigateTo(url=event.value)">
<option value="http://google.com">google.com</option>
<option value="http://yahoo.com">yahoo.com</option>
<option value="http://bing.com">bing.com</option>
</select>
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You are using button and onclick function, in place of this in AMP you can use anchor tag <a href="Value">Value</a>
and change the url using `amp-bind'
You can use amp-bind
to achieve your goal
Here is working URL
add JS in header
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
Add code in body
<div class="wrapper">
<select on="change:AMP.setState({ url: event.value })">
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>
<a [href]="url" href="home">ir</a>
</div>
Updated - if some one want to redirect on option change than use navigateTo
action
Example :
<select on="change:AMP.navigateTo(url=event.value)">
<option value="http://google.com">google.com</option>
<option value="http://yahoo.com">yahoo.com</option>
<option value="http://bing.com">bing.com</option>
</select>
add a comment |
up vote
1
down vote
You are using button and onclick function, in place of this in AMP you can use anchor tag <a href="Value">Value</a>
and change the url using `amp-bind'
You can use amp-bind
to achieve your goal
Here is working URL
add JS in header
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
Add code in body
<div class="wrapper">
<select on="change:AMP.setState({ url: event.value })">
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>
<a [href]="url" href="home">ir</a>
</div>
Updated - if some one want to redirect on option change than use navigateTo
action
Example :
<select on="change:AMP.navigateTo(url=event.value)">
<option value="http://google.com">google.com</option>
<option value="http://yahoo.com">yahoo.com</option>
<option value="http://bing.com">bing.com</option>
</select>
add a comment |
up vote
1
down vote
up vote
1
down vote
You are using button and onclick function, in place of this in AMP you can use anchor tag <a href="Value">Value</a>
and change the url using `amp-bind'
You can use amp-bind
to achieve your goal
Here is working URL
add JS in header
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
Add code in body
<div class="wrapper">
<select on="change:AMP.setState({ url: event.value })">
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>
<a [href]="url" href="home">ir</a>
</div>
Updated - if some one want to redirect on option change than use navigateTo
action
Example :
<select on="change:AMP.navigateTo(url=event.value)">
<option value="http://google.com">google.com</option>
<option value="http://yahoo.com">yahoo.com</option>
<option value="http://bing.com">bing.com</option>
</select>
You are using button and onclick function, in place of this in AMP you can use anchor tag <a href="Value">Value</a>
and change the url using `amp-bind'
You can use amp-bind
to achieve your goal
Here is working URL
add JS in header
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
Add code in body
<div class="wrapper">
<select on="change:AMP.setState({ url: event.value })">
<option value='home'>home</option>
<option value='contact'>contact</option>
</select>
<a [href]="url" href="home">ir</a>
</div>
Updated - if some one want to redirect on option change than use navigateTo
action
Example :
<select on="change:AMP.navigateTo(url=event.value)">
<option value="http://google.com">google.com</option>
<option value="http://yahoo.com">yahoo.com</option>
<option value="http://bing.com">bing.com</option>
</select>
edited Nov 9 at 11:22
answered Apr 26 at 12:44
Bachcha Singh
2,16721025
2,16721025
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50027232%2fhow-to-redirect-a-page-amp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to Stack Overflow! Unfortunately, your problem is hard to understand as-is, and could use some clarification (what is "the thing")? What have you tried so far?
– Jonathan Lam
Apr 25 at 16:36
please move your comment code into the actual question. Not everyone reads comments as they are very difficult to parse without formatting.
– Mozahler
Apr 25 at 17:16