开发者

Passing arguments to an iframe

I am building an IFrame for the first time and trying to make a widget.

What I am trying to do is let people pass a hike id and then display on a google map everything that happened on that hike. Right now I am just starting to get into how to make this a widget.

I need to pass the hike id variable into the widget, but I am not sure how, or whether things are done this way.

What I have now is one page called widget.php with this code:

<bl开发者_StackOverflow社区ink>
        <iframe src="hike_widget.php" width="100%" height="300">
    </iframe>
</blink>

And that is accessed by this URL: http://www.comehike.com/outdoors/widget.php?type=hike&hike_id=108

And then called the hike_widget.php file which displays text. Is this the general way to do this? How do I pass the hike id from widget.php to hike_widget.php ?

Thanks, Alex


You'd pass the hike_id like this:

<iframe src="hike_widget.php?hike_id=108" width="100%" height="300"></iframe>


You can achive it with the form also. Here's a simple example with post method:

<form action="hike_widget.php" target="hike_widget" method="post">

  <input type="number" name="hike_id">

  <button type="submit">Pass arguments</button>

</form>

<iframe name="hike_widget" src="hike_widget.php"></iframe>

P.s. You can also use get method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜