Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -360,14 +360,19 @@ def display_articles():
|
|
| 360 |
with open(selected_file, 'r', encoding='utf-8') as file:
|
| 361 |
html_content = file.read()
|
| 362 |
|
| 363 |
-
# Use JavaScript to open content in new window
|
| 364 |
-
|
| 365 |
<script>
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
</script>
|
| 370 |
-
"""
|
|
|
|
| 371 |
|
| 372 |
except Exception as e:
|
| 373 |
st.error(f"Error opening article: {str(e)}")
|
|
|
|
| 360 |
with open(selected_file, 'r', encoding='utf-8') as file:
|
| 361 |
html_content = file.read()
|
| 362 |
|
| 363 |
+
# Use JavaScript to open content in new window (safer approach)
|
| 364 |
+
js_code = """
|
| 365 |
<script>
|
| 366 |
+
function openArticle() {
|
| 367 |
+
var newWindow = window.open();
|
| 368 |
+
var content = """ + repr(html_content) + """;
|
| 369 |
+
newWindow.document.write(content);
|
| 370 |
+
newWindow.document.close();
|
| 371 |
+
}
|
| 372 |
+
openArticle();
|
| 373 |
</script>
|
| 374 |
+
"""
|
| 375 |
+
st.markdown(js_code, unsafe_allow_html=True)
|
| 376 |
|
| 377 |
except Exception as e:
|
| 378 |
st.error(f"Error opening article: {str(e)}")
|