doutangguan2460 2014-10-21 12:36
浏览 24
已采纳

写一行到javascript文件

Im using a array to display some images in a website:

var paintingImages;
paintingImages =
    [
        {
            url: 'images/objects/ron.jpg',
            alt: 'ron'
        }
    ];

This js code is written in paintings.js and my main js code is written in the file main.js

I have made this website for a artist and I want to give him the opportunity to login and add pictures to his website. I'm not that good with php, but adding images to a ftp in a folder is no problem.

Because I'm using a array for retrieving the images, I need to be able to add items to the array. This is the part where I'm stuck. I don't know how to edit a existing js file, so the next time I open the website, the items (images) will been shown.

Activexobject is not a option because it's only possible in IE.

In summary:

  • I need to add a item to a array
  • I need to save this into the file, so the next time the website opens, it will be shown
  • I'm not verry good with php, I prefer javascript
  • Can't use Activexobject because of the use of multiple browsers
  • 写回答

3条回答 默认 最新

  • duancuo1234 2014-10-21 12:47
    关注

    You can not simply modify a javascript file sitting on the server from browser side javascript. You need to implement some server side logic.

    If you don't like PHP, but like JavaScript, check out NodeJS for example. With Node you should be able to build some lightweight serverside logic to modify your json array file with additional images.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题