Khi cần nhúng 1 trang web (URL) khác vào website của bạn dưới dạng iframe
Nếu website đó không cho phép mở dưới dạng iframe, website bạn sẽ hiển thị lỗi :)
Bạn cần kiểm tra trước để hiển thị phù hợp, code c# có thể dùng như sau:
//using using System.Net;
//check frame support
string frame_support;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(iframeUrl);
using (WebResponse response = request.GetResponse())
{
//DENY, SAMEORIGIN, ALLOW-FROM
//null is open in iframe
frame_support = response.Headers["X-Frame-Options"];
}
Không có nhận xét nào:
Đăng nhận xét